MVC4 Bundles returns 404 - c#

I have a project that works with bundling when you run it from within visual studio. However, after you do a deployment, the bundling handler never seems to pick up the route. It ends up going to the static file handler instead, which returns a 404 response.
Any ideas? I see the optimization assembly in the bin of the website under IIS.
It's using the 4.0 app pool and integrated mode.
I'm wondering if anyone has any ideas or suggestions?
Thanks
----- update based on questions -----
VS2012
targetFramework="4.5"
I also added some code into the view to show which modules were loaded and I can see the bundle module listed there.
BundleConfig is the default provided when using the Internet Application MVC4 project template.
The site is being deployed into the root. It's odd as when I set EnableOptimizations = true (due to running in debug mode via visual studio F5), it works perfect! I can navigate to content/css and it spits out the combined css.
I deploy it over and everything else works, but bundling!

I've just hit (and solved) this problem.
Make sure your bundle's virtual path can't be confused for an existing directory or actual file name. In my case, I'd coded it as:
bundles.Add(new ScriptBundle("~/bundles/main.js").Include( ...
But when I changed it to
bundles.Add(new ScriptBundle("~/bundles/main").Include( ...
it all started working.

Updated Answer on 11/17/2013
This is caused by the fact that the default MVC routing only handles * instead of * . *, i.e. IIS or IIS Express's applicationhost.config has the following:
<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />
So to workaround it, we can add the following to the web.config:
<system.webServer>
<handlers>
<add name="UrlRoutingHandler"
type="System.Web.Routing.UrlRoutingHandler,
System.Web, Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
path="/bundles/*"
verb="GET"/>
</handlers>
</system.webServer>
For more information, you can reference the following:
http://weblogs.asp.net/owscott/archive/2013/01/16/handing-mvc-paths-with-dots-in-the-path.aspx
ASP.NET MVC Url Route supporting (dot)
Old wrong answer:
Basically, DOT is generally not allowed in virtual path when IIS parse URLs.
This a Link mentioned the following URLScan AllowDotInPath parameter:
By default, this option is set to 0. If this option is set to 0, URLScan rejects any request that contains multiple periods (.). This prevents attempts to disguise requests for dangerous file name extensions by putting a safe file name extension in the path information or query string portion of the URL. For example, if this option is set to 1, URLScan might permit a request for http:// servername/BadFile.exe/SafeFile.htm because it interprets it as a request for an HTML page, when it is actually a request for an executable (.exe) file with the name of an HTML page in the PATH_INFO area. When this option is set to 0, URLScan may also deny requests for directories that contain periods.

Even I got the same error.
Adding <modules runAllManagedModulesForAllRequests="true" /> under <system.webServer> in web.config file solved the problem.

I had the same problem even with sample MVC application. I saw the default template bundles the style-sheet with css name which i guess IIS does not likes resulting in 404 error.
Changing the bundle name from css to APPCSS will resolve the issue for me.

Related

IIS 10 can't read web.config (try to deploy Blazor), Error 500.19 with 0x8007000d [duplicate]

I am replicating web application deployment and found several issues related to HTTP Error 500.19. My machine is running Windows 7 while the working development is using Windows 8. We're developing our Web Application using Visual Studio 2010.
First, I got error code 0x80070021, similar as posted here.
I update my web.config according to the accepted answer and then I got following error code (which is similar as posted here).
HTTP Error 500.19 - Internal Server Error
Error Code 0x8007000d
Config Source -1: 0:
I have read the symptoms definition in Microsoft support page and cause of the error is:
This problem occurs because the ApplicationHost.config file or the Web.config file contains a malformed XML element.
and the solution is
Delete the malformed XML element from the ApplicationHost.config file or from the Web.config file.
However, the web.config that I used is working perfectly in the original development environment.
Here is what I have checked and tried so far:
Install ASP.NET by calling aspnet_regiis -i
Set my application to use different application pool (ASP.NET v4.0, .NET v4, etc)
ApplicationHost.config file is still using default from Windows 7.
This is part of my Web.Config
<system.webServer>
<section name="handlers" overrideModeDefault="Allow" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
</modules>
<handlers>
<remove name="UrlRoutingHandler" />
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
<urlCompression doStaticCompression="true" doDynamicCompression="false"></urlCompression>
<directoryBrowse enabled="true" />
<defaultDocument>
<files>
<add value="Logon.aspx" />
</files>
</defaultDocument>
</system.webServer>
I have read similar/duplicates/closed posts (around 13) posts in stackoverflow, tried all except the answer related to Ajax (is it related) and still have no clue on what the error is.
Does anyone one how to fix this error? (And if possible, a comprehensive lists of things need to be checked so we can reduce similar posts like this.) I am ready to provide more details.
Error 0x8007000d means URL rewriting module (referenced in web.config) is missing or proper version is not installed.
Just install URL rewriting module via web platform installer.
I recommend to check all dependencies from web.config and install them.
When trying to set up a .NET Core 1.0 website I got this error, and tried everything else I could find with no luck, including checking the web.config file, IIS_IUSRS permissions, IIS URL rewrite module, etc. In the end, I installed DotNetCore.1.0.0-WindowsHosting.exe from this page: https://www.microsoft.com/net/download and it started working right away.
Specific link to download: https://go.microsoft.com/fwlink/?LinkId=817246
Yes, for .net core apps, install dotnet hosting. This worked for me.
And here it is for .net6
And now if you need .net7
Install URL rewriting:
UPDATE - this is now available here (and works with IIS 7-10):
https://www.iis.net/downloads/microsoft/url-rewrite
Ensure you have the following set to 'Allowed' for your IIS server:
In my case, because I had reinstalled iis, I needed to register iis with dot net 4 using this command:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
In my case (.Net Core Web API) for this issue HTTP Error 500.19 – Internal Server Error 0x8007000d
First download dotnet-hosting-3.0.0-preview5-19227-01-win (.Net Core 3) or dotnetcore 2 hasting windows
https://download.visualstudio.microsoft.com/download/pr/5bed16f2-fd1a-4027-bee3-3d6a1b5844cc/dd22ca2820fadb57fd5378e1763d27cd/dotnet-hosting-3.1.4-win.exe
Any .net core 3.1 application either angular or mvc application would need this.
Second install it as Administrator
Open cmd as administrator, type iisreset, press enter
So refresh your localhost app
Best regard
M.M.Tofighi from Iran
A repair of the DotNetCore hosting bundle did the trick for me. :/
Installing ASP.NET Core Runtime Hosting Bundle solved the issue for me. Source: 500.19 Internal Server Error (0x8007000d)
Kind of late to the party here, but I have just been struggling with the exact same issue (symptoms) and cursing the lack of error detail reporting.
It worked fine on IIS 8+ machines but Win 7 got these INSTANT HTTP 500.19 errors.
For me it was as silly as having an unsupported configuration element in the config file:
<applicationInitialization doAppInitAfterRestart="true">
<add initializationPage="/" />
</applicationInitialization>
So while running old web.config files worked fine, I just diffed them and started chopping away at new blocks until I got the page to start loading. Had I seen this as an answer I would have gone this route immediately as I knew none of the popular solutions were relevant. So there you go :)
I turn on .Net Framework 3.5 and 4.5 Advance Service in Control Panel->Programs and Features->Turn Windows features on or off.it work for me.
Problem solved. Here are the steps that I tried:
Enable the 32-bit application in IIS -> Application pool -> Advanced settings
Copy System.EnterpriseServices.dll and System.EnterpriseServices.Wrapper.dll from C:\Windows\Microsoft.NET\Framework\v2.0.50727 to the application bin folder
Do comments/uncomments to sections on the web.config and found that problem related to the referenced DLL.
The config that I commented the previous one that I added:
<section name="handlers" overrideModeDefault="Allow" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow"/>
Add the required FasterFlect.DLL used by Combres.DLL v2.1.0.0 to the application bin folder (shall download the full zip from Combres codeplex, because the required fasterflect DLL V2.0.3732.24338 cannot be found in fasterflect codeplex) and other DLLs. For convinience, use the full Combres.DLL (1,3MB)
Check that the DLL versions and public key tokens are configured correctly in web.config using tool, e.g. .NET Reflector
I understand that this error can occur because of many different reasons. In my case it was because I uninstalled WSUS service from Server Roles and the whole IIS went down. After doing a bit of research I found that uninstalling WSUS removes a few dlls which are used to do http compression. Since those dlls were missing and the IIS was still looking for them I did a reset using the following command in CMD:
appcmd set config -section:system.webServer/httpCompression /-[name='xpress']
Bingo! The problem is sorted now. Dont forget to run it as an administrator. You might also need to do "iisreset" as well. Just in case.
Hope it helps others.
Cheers
For me, it was all about setting up my web server to use the latest-and-greatest tech to support my ASP.NET 5 application!
The following URL gave me all the tips I needed:
https://docs.asp.net/en/1.0.0-rc1/publishing/iis-with-msdeploy.html
Hope this helps :)
I had this problem with a brand new web service. Solved it by adding read-only access for Everyone on Properties->Security for the folder that the service was in.
I had the exact same error. It turned out that it was something was caused by something completely, though. It was missing write permissions in a cache folder. But IIS reported error 0x8007000d which is wildly confusing.
I have the same problem when I was trying to publish asp.net core 5.0 web app on my local IIS and the solution was to add the following inside System.webserver tag in my web.config file
<applicationInitialization doAppInitAfterRestart="true">
<add initializationPage="/" />
</applicationInitialization>
Reinstalling ASP.NET Core Runtime - Windows Hosting Bundle Installer made the trick for me... I belive the "ASP.NET Core Module" was missing.
For me I had a web.config file in one my root folders, this config file was for the live server so removing it allowed the site to run on the dev server.
So check for any web.config files in folders too.
In my case, i have installed dotnet hosting but error change to HTTP Error 503. The service is unavailable, but after install windows update KB2999226 and dotnet sdk, its work!
follow the procedure chronologically or it might fail due to missing or errors in redirecting.
install Runtime bundle e.g.. dotnet-sdk-7.0....
2.turn asp services on and internet services"Turn Windows features on or off" to enable IIS
3.install web hosting bundle iis 7.0 e.g dotnet-hosting-7.0.2...
this worked for me

IIS: how to add a module to be run by the Default Web Site?

I have a couple of web applications deployed in an IIS Server (IIS 7.5 in W2k8 R2). In order to remove some HTTP Response Headers, I created a module (C# .dll), copied this .dll to each bin folder of each web application, and reference this module in the web.config of each one like below:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="MyModule" type="MyNamespace.MyClass" />
</modules>
</system.webServer>
From that point on, when I check the Module section of the web application in IIS, the reference is there and it works fine (the headers are not in the HTTP response).
PS.: I was not successful in using the GAC, anyways...
Here is what happens:
when I connect to https://example.com/myapp the header is not present in the response, as expected.
when I connect to https://example.com the header is present, as I didn´t want, but that is expected because I didn´t touch the Default Web Site at this point. Also, this Default Web Site is just an HTML redirection to one of the webapps.
The problem is, when it comes to the Default Web Site, I can´t find its web.config, nor do I find the place where I drop the .dll. Can anyone help?
IIS has a global machine-level configuration file. All web.config files are essentially inheriting from that one. It works something like this (source):
You could simply add your module into the machine.config file and it will automatically be added to all sites. See this question to locate that file.

Change targetFramework on IIS

In my ASP.NET 5 application, I generate a drop-down list thanks to the HtmlHelper. Anything works fine in localhost except in production, we have a 500 server error.
I was able to find the cast which is performed, on github, and it's performed into the MVC lib, precisely into the DefaultHtmlGenerator class :
This cast is performed when we want to render a drop-down list depending on the SelectList we pass in parameter.
We can see that the comment specify we have to use at least the version 4.5 of the framework. At the end of the stacktrace we see the version of the framework which is used in production :
However, the version 4.5 is installed on our server, and I tried to insert a web.config file into the wwwroot of the projet to force the target framework :
But it doesn't work, and we indicate correctly the framework we want to use into our project.json :
So my question is : can we use compilation targetFramework="4.5" and httpRuntime targetFramework="4.5" to force IIS for using the version 4.5 ?
NOTE
You are trying to run in IIS managed code. You can't do that. IIS doesn't manage the process anymore. Basically, IIS is going to run an EXE and is going to forward requests to it. That's it.
Check the procedure bellow to properly deploy a DNX application to IIS. Or better, read the documentation right here: http://docs.asp.net/en/latest/publishing/iis.html
Requirements
Windows 7 or better
Windows Server 2008 R2 or better
Have IIS installed
Procedure
First, make sure you have the HTTP Platform Handler installed in your IIS (x86 / x64).
Publish your application to the file system and take the content of the \artifacts\bin\MyWebApp\Release\Publish folder and copy it into your IIS Server.
When configuring your application, target the wwwroot folder that you copied over.
Now you'll need to unlock the system.webServer/handlers section which can be found in IIS Manager on the server node under Configuration Editor. Search for the right section and unlock it from the right action pane.
Make sure that the App Pool is set to No Managed Code. DNX is being run as an external process. IIS doesn't need to know about what it's currently running.
Finally, create a web.config with the following content:
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
</system.webServer>
</configuration>
It should be running at that point.
Source

Telerik RadControls, controlling where ScriptResource.axd files are generated when EnableEmbeddedScripts is true

In Telerik RadControls, how do you control where the ScriptResource.axd files are generated when EnableEmbeddedScripts is true?
By default, it renders them in the root of my web app and
<add key="Telerik.WebControls.RadControlsDir"
value="~/Resources/RadControls/"/>
Doesn't appear to work, EnableEmbeddedScripts is not false.
As described in the ScriptResourceHandler MSDN page, ScriptResourceHandler is merely a "class that processes all requests for embedded script files".
It generates output that you can see in browsers developement tool (ie: chrome) but the generated content itself is not stored on the server. Instead, resources used to generate this content output are compiled within the application (this is a the "build action : Embedded Resource" in files properties).
Additionnal note: the handler is usually defined by the following section in the Web.config file (although Telerik might use a custom handler for their files such as themes / javascript):
<httpHandlers>
<add verb="GET,HEAD" path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>
I don't know if this answer can help you, but I found this information - most probably you already know it but I'm pasting it here anyway, who knows?
It says that this preference is not working when you're using Visual Studio built-in web server (as most developers does) and NOT IIS.
"NOTE: The approaches suggested in this article will not work when you're using the built-in VS 2005 web server. They will only work when your site is running in IIS because the VS 2005 internal server does not support virtual directories. If you are testing locally (and not using IIS), you must have a copy of the RadControls folder in your web application."
The note has been taken from here and it's about VS2005:
http://www.telerik.com/support/kb/aspnet-ajax/general/changing-the-location-of-the-radcontrols-or-setting-scripts-folder.aspx
EDIT 1: moreover, it's working when the UseEmbeddedScripts property of the control is set to false, so it's not your case. Well, I hope it's useful anyway.
EDIT 2: I found another link that could help to better find a solution. As #cahmadzadeh said, those are Http Handlers and they're most probably managed outside Telerik:
http://forums.asp.net/t/1546423.aspx

Ajax FileUpload Route/Querystring - DirectoryNotFoundException

I have a WebApp with an upload section.
To upload the files to a sql database I'm using a Ajax Toolkit Fileupload control.
I always get a similar error as in this post, but after hours of testing, I figured out what is causing my Problem.
My upload control is located on the SidDetails.aspx page and if open the page directly
with
foo.com/Pages/SID/SidDetails.aspx
I'm able to upload files.
but if I access the page via the route
foo.com/SID/My/1
I get a 500 internal server error
So I checked the link of the page that is causing the exception
foo.com/SID/My/1/?contextKey={DA8BEDC8-B952-4d5d-8CC2-59FE922E2923}&done=1&guid=BD327457-2013-1E97-6ADE-28612D63758E
For me, it looks like that is the problem, but I don't know how to fix this.
I already tried adding a route with query value
But i don't know if this is how you would approach it.
Could not find a part of the path 'C:\Windows\TEMP_AjaxFileUpload\E0E386A6-F5B5-1012-F6E5-1872E4D6EF69'.
Thats the exception that is thrown by the upload control.
I would like to keep the routes but how can I fix the problem?
I'm using Visual Studio 2012, .net 4.5 and AjaxControlToolkit 7.0930
Kind regards
CarnVanBeck
I run into this too, and after going crazy I fixed it.
Download the ajaxtoolkit source code project and open it.
Change the following row:
this._uploadUrl = 'AjaxFileUploadHandler.axd';
to:
this._uploadUrl = '/AjaxFileUploadHandler.axd';
Rebuild the project, get the new .dll and copy it to your /bin directory.
This will fix the issue, giving the right path to the handler.
PS: I came to this as:
I noticed some strange duplicated calls to the handler, happening only in routed paths
(like www.site.com/projects/edit/mypage), where uploads failed.
I noticed that in a test page, placed in the home dir of my site, the uploader was working fine.
Then I came to this page and noticed the mentioned row.
If your app is running in Integrated Mode pool, you have to add this lines in the web.config file:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd"
type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>

Categories

Resources