scriptreference named respond no longer works - c#

Using: Visual Studio Express 2013 for Web to write a .NET 4.5.1 site.
Project initially built on the default "Create New Website" template therefore the parts in question were added to my project by the IDE and have not been edited.
This has been a several weeks long project and today I began receiving an error out of the blue in relation to "canned" items added at create time. It has been working without error until now.
The error message is:
Server Error in '/' Application.
'respond' is not a valid script name. The name must end in '.js'.
I have debugged this to be directly related to this line in my site.master file:
<asp:ScriptReference Name="respond" />
SEE COMMENT HERE This reference is contained in the section of my master file:
This is part of the much larger group of scriptreferences added by the IDE at create time.
In troubleshooting I have tried adding the .js; add a path attribute to the actual file; and commented out the line entirely.
Adding the extension and/or the path results in a different error:
Server Error in '/' Application.
The assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' does not contain a Web resource that
has the name 'respond.js'. Make sure that the resource name is spelled correctly.
The only successful troubleshooting has been commenting it out BUT this breaks another key feature: Accessing my links requires the .ASPX extension now as previously I could access my links without specifying the extension on my file... and this is the default way the project was created via the ide, so with this fix in place, none of my links work without editing each and every one to include and extension. NOT IDEAL.
I've tried using the Package Manager to update and nothing has been successful there. I have also verified the respond.js file exists in my scripts folder as do the others like bootstrap.
I have searched here and googled for quite some time but there are so many unrelated results that contain excerpts from the scriptmanager that the results are endless.
I am unsure of the correction needed for this or if other files are required. Rebuilding my site has no effect, I've removed "temp" files per one post I read that said it might work for a different but similar issue.
What is the corrective action for this error?

In Site.Master file locate the line:
<asp:ScriptReference Name="respond"/>
and modify to:
<asp:ScriptReference Name="respond" Assembly="System.Web.Extensions" />

I ran into this same issue myself and fixed it by doing the following.
Add the following code to the RegisterBundles method of the BundleConfig class:
ScriptManager.ScriptResourceMapping.AddDefinition(
"respond",
new ScriptResourceDefinition
{
Path = "~/Scripts/respond.min.js",
DebugPath = "~/Scripts/respond.js",
});

I had the same problem, and none of the above worked...
Verify your global.asax.cs, the Routeconfig and BundleConfig lines were missing in my case, after adding them, it worked again.
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}

Solution:
Compile the project at the production server, instead of precompiling on at development machine.
If using VS one click publishing tool, under "Settings", make sure "Precompile during publishing" is unchecked.

This problem occurred for me when I deployed a template asp.net web forms application generated from Visual Studio (2015 in my case) to Azure app service.
For me, none of the solutions given above worked. I got the errors exactly as described in this question.
Then I chanced upon the following article that shows an example of adding a jquery bundle.
Adding Bundling and Minification to Web Forms
Following that example, I removed the template code for AddDefinition for "respond" in RegisterBundles method. Then I added the following and rebuilt and uploaded the application dll.
bundles.Add(new ScriptBundle("~/bundles/respond").Include(
"~/Scripts/respond.min.js"));
Then I added the following to Asp:PlaceHolder in site.master.
<%: Scripts.Render("~/bundles/respond") %>
Finally, I removed the inclusion of respond in ScriptManager in site.master.

It seems your bundleConfig isn't starting up.
Try to rebuild and clean the project first. After that, try to look into the file Global.asax.cs and see if there is something wrong.
Or try to get a default Global.asax.cs file and copy it into it.

I tried the above methods without much success.
Then I tried as indicated by another post
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
in between
and in web.config
works like a charm.
Graham
https://forums.asp.net/t/1857743.aspx?Bundling+not+working+when+deployed+to+web+host+works+fine+locally

Related

ASP.Net 5/MVC6 Razor views not updating with changes in browser unless I restart IIS Express

I currently have an MVC6/ASP.Net 5 project. I "start without debugging" and the app loads in the browser. I can make changes to .cs files and recompile and they show in the app.
However, when I make any changes to razor files (*.cshtml) they don't show at all. I have to kill IIS express and re-launch in order to get the change to show. The rest of my team is working on the same code base/solution and it is working fine for them.
I have updated to VS SP1, and re-installed the tooling. No luck.
Please help!
Most probably you have the .csproj MvcBuildViews property set to true. To check, unload the project (right-click it) and then edit it with the text editor.
The property gets rid of the "lag on first visit of view", but increases build times (and startup times) as well as introducing situations like this.
If you have it enabled, only enabling the property on Release (and not Debug) configurations might help:
Replace the <MvcBuildViews>true</MvcBuildViews> with the following:
<MvcBuildViews Condition="'$(Configuration)'=='Debug'">false</MvcBuildViews>
<MvcBuildViews Condition="'$(Configuration)'=='Release'">true</MvcBuildViews>
---------- EDIT ---------
Actually, sometimes this is not enough. Most probably (after the one above), you have the optimizeCompilations="true" attribute set on the <compilation> element inside <system.web> in your web.config.
If you don't want to remove that, you can periodically remove all the contents of this folder: %localappdata%\Temp\Temporary ASP.NET Files\vs (yes, you can enter that directly into the file explorer address bar)
Also, try the suggestion in my OP-comment:
A temporary rescue is to add a cache-buster to the browsed URL
(?nocache=1, 2 etc) and at the same time introduce a Razor c# syntax
error. Then, after reloading, remove the syntax error and the page
will be reloaded...
I had the same issue.
Closing Visual Studio and deleting .vs folder in the solution directory worked for me.
I think my IIS Express's configuration was corrupted. This may be why it worked for me.
It's a bug, and I found an answer to this that solves it here on StyackOverflow.
Other Stack article here
Try clearing out your IISExpress cache / application space:
https://gyorgybalassy.wordpress.com/2013/12/02/cleaning-up-iis-express-configuration/
It's worked wonders for me before.

TFS build fails: The type X exists in both

We have a website (not webApp, framework 3.5) we are trying to build in our TFS build server.
The build is defined to trigger on each check-in. The build passed successfully on local machine (VS2010).
However, It fails to build on the TFS build server(2012) because of the following error:
The type X exists in both
'c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET
Files....\App_Web_wk4sskb7.dll' and
'c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET
Files....\App_Web_wazvuwk6.dll'
We thought the reason for that is 2 MasterPages that inherits from the same page but we copied the same projects to a new solution and defined the same build definitions (under different TFS project) and the build was successful.
We want to figure out how is that possible, because this is not a suitable solution for us.
We want the original solution to pass successfully.
We got the same problem on several occassions when publishing a website. We always solved it by deleting the contents of the "bin" folder and re-publish the website.
I don't really know what is causing this problem in the .NET framework though. It would be nice if someone could explain it.
Is this not just a case of the temporary asp.net dll's being created when the website first spins up?
I'm assuming the .. contains a folder with the web site name
I've had issues before with similar things, try clearing the temporary folder and if that works, include a delete task as part of the build process
The problem was that we have 2 MasterPages that had the same CodeFile.
We separated them and the build passed successfully.
Clear the bin folder
Build VS 2012
Build succeeded
Worked for me
We had the same problem when building in Azure CI Pipeline.
The issue was changing some of the Control Tag Names
Current:
<%# Register Src="CustomerInfo.ascx" TagName="CustomerInfo" TagPrefix="uc1" %>
Change to:
<%# Register Src="CustomerInfo.ascx" TagName="CustomerInfoA" TagPrefix="uc1" %>
Which resolved the issue.

Parser Error Message: Could not load type

We are working on a Web Application.We are using ASP.net with c# (3.5 framework). We are Continue getting this error on a specific page
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'Page Name'.
Each time we build the solution & upload the file,it will work and then suddenly after 2 to 3 days same problem again.Please help me resolve the issue.Thanks in Advance.
We found 2 things,may be that will help in future who will face an issue.
a)The file in which we have changed it was not updated properly,so
that's why It was causing an error,so project .dll has updated but
that page was not updated properly.
b)That page Excluded from the project.
so Please keep these thing in your mind.Most of the cases files was not updated.
Thanks.
This happened to me after creating a new page. It turns out I was running under x86 CPU instead of Any CPU mode under the Configuration Manager. When testing in debug mode the application was running against the local bin, but the file was actually being placed in the bin/x86 directory until I reconfigured it.
It sounds to me like there is some other software on the machine (anti-virus, backup, indexing software, ???) that is modifying the page source.
You could try making the directory or file readonly after uploading it to see if that resolves the problem.
Check the Inherits property of your page directive. It may have a number of attributes, but I suspect it will contain at least the following:
<%# Page Language="C#" Inherits="Page Name" %>
Change the value of Inherits to the fully qualified name of the class outlined in the page's code behind file, i.e. something like: MyProject.MyFaultyPage. If you don't have a code behind file for that page, you can inherit System.Web.UI.Page.
Close Visual Studio and select the solution folder and uncheck Readonly that will solve your issue!

How to validate ASPNET AJAX installation

How can I validate that my ASPNET AJAX installation is correct.
I have Visual Studio 2008 and had never previously installed any AJAX version.
My UpdatePanel is nto working within IIS6, although it works ok within Visual Studio's web server. The behaviour I get is as if the UpdatePanel doesnt exist at all - i.e. it reverts back to 'normal' ASPX type behavior.
I tried installing AJAX from MSDN followed by an IISRESET yet still it is still not working properly.
What can I check to diagnose the problem?
Update: When running within Visual Studio (Cassini) I get the following 3 requests shown in Fiddler:
http://localhost:1105/RRStatistics/WebResource.axd?d=k5J0oI4tNNc1xbK-2DAgZg2&t=633564733834698722
http://localhost:1105/RRStatistics/ScriptResource.axd?d=N8BdmNpXVve13PiOuRcss0GMKpoTBFsi7UcScm-WmXE9jw5qOijeLDcIyiOsSQZ4k3shu0R2ly5WhH2vI_IbNVcTbxej1dkbdYFXrN6c7Qw1&t=ffffffff867086f6
http://localhost:1105/RRStatistics/ScriptResource.axd?d=N8BdmNpXVve13PiOuRcss0GMKpoTBFsi7UcScm-WmXE9jw5qOijeLDcIyiOsSQZ4AsqNeJVXGSf6sCcCp1QK0jdKTlbRqIN1LFVP8w6R0lJ_vbk-CfopYINgjYsHpWfP0&t=ffffffff867086f6
but when I run within IIS i only get this single request :
http://www.example.com/RRStatistics/ScriptResource.axd?d=f_uL3BYT2usKhP7VtSYNUxxYRLVrX5rhnXUonvvzSEIc1qA5dLOlcdNr9xlkSQcnZKyBHj1nI523o9DjxNr45hRpHF7xxC5WlhImxu9TALw1&t=ffffffff867086f6
Now the second request in Cassini contains a javascript file with 'partial rendering' as one of the first comments. I'm sure this is the source of the problem, but I cannot figure out why in IIS i dont get the other requests.
Check for any JavaScript errors. Sometimes the JavaScript required for the UpdatePanel to work fails to load.
Haven't tried this myself, but I found several forum postings recommending the following
Try and add the following to your
web.config
within
<system.webServer><handlers>
<add verb="GET"
path="ScriptResource.axd"
type="Microsoft.Web.Handlers.ScriptResourceHandler"
validate="false" />
Another option would be to check your web.config. You could for example create an new Ajax enabled ASP.NET website from Visual Studio. This will generate a correct web.config. Copy over all non-ajax sections from your existing web.config and you're set. This worked for me.
-Edoode

ASP.NET controls cannot be referenced in code-behind in Visual Studio 2008

Ok, so, my visual studio is broken. I say this NOT prematurely, as it was my first response to see where I had messed up in my code. When I add controls to the page I can't reference all of them in the code behind. Some of them I can, it seems that the first few I put on a page work, then it just stops.
I first thought it may be the type of control as initially I was trying to reference a repeater inside an update panel. I know I am correctly referencing the code behind in my aspx page. But just in case it was a screw up on my part I started to recreate the page from scratch and this time got a few more controls down before VS stopped recognizing my controls.
After creating my page twice and getting stuck I thought maybe it was still the type of controls. I created a new page and just threw some labels on it. No dice, build fails when referencing the control from the code behind.
In a possibly unrelated note when I switch to the dreaded "design" mode of the aspx pages VS 2008 errors out and restarts.
I have already put a trouble ticket in to Microsoft. I uninstalled all add-ins, I reinstalled visual studio.
Anyone that wants to see my code just ask, but I am using the straight WYSIWYG visual studio "new aspx page" nothing fancy.
I doubt anyone has run into this, but have you?
Has anyone had success trouble shooting these things with Microsoft? Any way to expedite this ticket without paying??? I have been talking to a rep from Microsoft for days with no luck yet and I am dead in the water.
Jon Limjap: I edited the title to both make it clear and descriptive and make sure that nobody sees it as offensive. "Foo-barred" doesn't exactly constitute a proper question title, although your question is clearly a valid one.
The above fix (deleting the temp files) did not work for me. I had to delete the PageName.aspx.designer.cs file, then right-click my page, and choose "Convert to Web Application" from the context menu.
When Visual Studio attempted to rebuild the designer file, it encountered (and revealed to me) the source of the problem. In my case, VS had lost a reference to a DLL needed by one of the controls on my page, so I had to clean out the generated bin folders in my project.
try clearing your local VS cache. find your project and delete the folder. the folder is created by VS for what reason I honestly don't understand. but I've had several occasions where clearing it and doing a re-build fixes things... hope this is all that you need as well.
here
%Temp%\VWDWebCache
and possibly here
%LocalAppData%\Microsoft\WebsiteCache
Is the control that you are trying to reference inside of the repeater?
If so then you need to look them up using the FindControl method.
For example for:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server">stest</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
You would need to do this to reference it:
LinkButton lb = Repeater1.FindControl("LinkButton1");
In my case, I was working with some old web site code, which I converted to a VS2008 solution. I encountered this same problem.
For me, the fix was to right-click the Web Sites project in the Solution Explorer and select Convert to Web Application. This created designer.cs files for all pages, which did not yet have these files before.
you will also find .net temp files which are safe to delete here:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
I observed this happens because of missing .designer.cs file. Following fixed this issue in my case (basically I had these files copied from VS 2005 web project to VS 2010 project): Right Click on .aspx file and select menu "Convert to Web site", this will create .designer.cs file and then it should work file.
In my case new asp controls I added to an existing were not being detected.
What worked for me was forcing a recompile by renaming an existing control to break the build eg: changing <asp:TextBox ID="txtTitle" runat="server" /> to <asp:TextBox ID="txtTitle2" runat="server" />
When I corrected the ID and rebuilt a new designer file was generated with the corrected ID and new controls.
right click on project name and select "Clean". then, check your bin folder if it has any dll remaining. if so, delete it. that´s it. just rebuild and every thing will work fine.
This can also happen if the Inherits property on the source page doesn't match the class name in the code behind. Generally speaking, this would probably only happen if you copy/pasted a .ascx/.aspx file and forgot to update it.
Example:
<%# Control AutoEventWireup="false" CodeBehind="myControl.ascx.vb" Inherits="myProject.myWrongControl" %>
The the code behind class:
Partial Public Class myControl
we cannot change the code when the application is running .To do so first click on the stop button on the top which will halt your application .now click on the button in design mode ,it will insert the code in .aspx.cs file ,then write the code in it
Check out your aspx file on errors, once I've faced with that problem
I had this happen a few times and it happened again today for a new reason. I normally run my project through IIS but needed to run it locally to debug. I normally run on port 80 in IIS and 81 in debug, but I had some settings in the web.config that used 80 so I just killed the site in IIS and switched the website to port 80 in the project settings. For whatever reason, this messed everything up and created the problem described in the OP. I started trying things one by one, including all the advice mentioned here, but switching the port back to 81 in the project settings is what ended up working.
For me, deleting/renaming the files in the following location worked:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myvirtualwebsite\e331e0a9
Just to add my two cents with this problem.
The only thing from all the above that worked for me was the "Clean" and then delete anything left in the bin folder. Rebuild and all controls started working then.
FYI...I was having this problem too and I ended up fixing it by deleting the existing .designer.vb file, right-clicking on the project and choosing Convert to Web Application. It then showed the real "error" that was causing the GUI to crap itself. Turned out I had used the same name for 2 other labels but that wasn't being shown in the error list window. Once I renamed one of the 2 other labels it built fine and stopped giving me trouble.
You have to add
runat="server"
to each element in your page.

Categories