Mvc Mini Profiler requests for files with and without RouteBasePath - asp.net-mvc

This is driving me crazy, I'm testing my app with both Firefox and IE, on Firefox works just fine, but on IE mini profiling is making these 5 requests
/Content/mvc-mini-profiler/mini-profiler-includes.css?v=1.9.0.0
/Content/mvc-mini-profiler/mini-profiler-includes.js?v=1.9.0.0
/Content/mvc-mini-profiler/mini-profiler-jquery.tmpl.beta1.js
/mini-profiler-includes.css?v=1.9.0.0
/mini-profiler-includes.js?v=1.9.0.0
I put the RouteBasePath to be ~/Content/mvc-mini-profiler but for some reason is also making requests without it.
Am I doing something wrong or is this some kind of bug?
Thanks.

For the last two
/mini-profiler-includes.css?v=1.9.0.0
/mini-profiler-includes.js?v=1.9.0.0
View the source and make sure you don't have any script or link elements with those urls in the src or href attributes. That would make a request to the server without your base url.

Did u added below code in you web config?? if not then add and try it
<system.webServer>
...
<handlers>
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
and also you can try with
<system.webServer>
<handlers>
<add name="UrlRoutingModule1" path="mini-profiler*.js" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
<add name="UrlRoutingModule2" path="mini-profiler*.css" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
<add name="UrlRoutingModule3" path="mini-profiler*.tmpl" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>

Related

Asp.Net Mvc Cloud hosting

Asp Net MVC project works fine in IIS Server ,But after uploading it to a cloud space ,it shows an error code 500.19 ,I put the database in cloud ,it also works fine with IIS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<handlers accessPolicy="Read, Script">
<add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe|-d open_basedir=C:" resourceType="Unspecified" requireAccess="Script" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="dotnet"
arguments=".\TickLogicApplication.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess"/>
<httpErrors errorMode="Detailed" existingResponse="PassThrough" />
</system.webServer>
</configuration>
and in my local project .Can some one give me a solution?

MVC5 routing error (404.0) error on IIS 7.5

An old story of everything works fine on the development machine but not on the host server.
HTTP Error 404.0 - Not Found
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Trying to produce the same error on the development machine by adding <remove name="UrlRoutingModule-4.0" /> to system.webServer - modules and resolving it when adding <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />, but that not works on the host. I've also try <modules runAllManagedModulesForAllRequests="true" /> but nothing changed.
And here is the handlers part:
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<remove name="WebDAV" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
Few more information:
MVC.Net 5.2.2.0
IIS 7.5 on Windows 2008
Integrated .Net 4.0 application pool.
Is there anything else that I should do?
Now, having the same problem in IIS8, any idea?
I had similar problem. It turns out to be discrepancy with Virtual folder name and the URL I was constructing to call Web API route:
var URLGetUserAccesses = "/api/Login/GetUserAccesses";
Vs.
var URLGetUserAccesses = "../api/Login/GetUserAccesses";

Javascript bundling in another folder

How can I have JavaScript bundling working from another folder (aside from the Script folder). If I do this:
bundles.Add(new ScriptBundle("~/bundles/search").Include("~/Views/Search/*.js"));
The browser tells me the javascript file can't be found. Is it possible to do this
or do all my sripts have to be in the Scripts folder?
Basically I want my Javascript included in my View subfolders
You need to change web.config in Views folder according this answer:
In ASP.NET MVC, how can I load script from my view folder?
Good example from Ashley Lee:
<system.webServer>
<handlers>
<add name="JavascriptViewHandler" path="*.js" verb="*"
preCondition="integratedMode" type="System.Web.StaticFileHandler" />
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*"
preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
Since you specifically want to only include javascript files, make the following change to your ~/Views/web.config file, by adding the "JavascriptViewHandler" section.
<system.webServer>
<handlers>
<add name="JavascriptViewHandler" path="*.js" verb="*"
preCondition="integratedMode" type="System.Web.StaticFileHandler" />
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*"
preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
This will preserve all of the current blocking for non-javascript files.
I don't know if i understood your question properly, but if you want to use a script file from any folder in a View or preferably in it's Layout, you can add the following tag in <head> section of you View or _Layout.cshtml:
<script src="#Url.Content("~/Scripts/jquery-ui.min.js")" type="text/javascript"></script>
You can mention the complete path to your script file instead of ~/Scripts/jquery-ui.min.js

Adding HttpHandler to MVC application

I have an MVC4 application to which I added an HttpHandler:
<system.web>
...
<httpHandlers>
<add path="Files" verb="*" type="MyHttpHandler" />
</httpHandlers>
</system.web>
I also ignored the relevant path in RegisterRoutes so that the requests to "Files" are not handled by MVC:
routes.IgnoreRoute("Files/{*pathInfo}");
The problem is that the MyHttpHandler is invoked only for requests to "Files", not for any of its children or sub-folders.
I've tried using the <location> element, but getting that to work means that you will be hard coding the application's virtual path in the "path" attribute (e.g., <location path='MyApp\Files'>).
What is the correct method to use to allow all requests for "Files" and any of its sub-folders (and sub-folders of those folder, etc) to get routed to MyHttpHandler?
Scratch that...<location> seems to work OK. Though, you need both the <web> and <webServer> entries to ensure that it works for both IIS and the Visual Studio Development Server. For example:
<location path="Files">`
<system.webServer>
<handlers>
<add name="MyHandler" path="*" verb="*" type="MyHttpHandler" />
</handlers>
</system.webServer>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="MyHttpHandler" />
</httpHandlers>
</system.web>
</location>

Enable Http PUT requests on .NET MVC

I'm working on an MVC application. On my original draft of the service I had this method in one of my controllers:
[AcceptVerbs(HttpVerbs.Post)]
[ActionName("UpdateRelationship")]
public ActionResult UpdateRelationship(string aParameter)
And that worked fine. In the latest revision I've been asked to change this into a PUT request to differentiate it from a similar add mechanism which uses post. So I changed it to this:
[AcceptVerbs(HttpVerbs.Put)]
[ActionName("UpdateRelationship")]
public ActionResult UpdateRelationship(string aParameter)
And suddenly I'm getting a 404 on my requests, all from just changing the AcceptVerbs. From the look of the error, it appears as though IIS is trying to route the request as a standard webforms page rather than using MVC extensionless url re-writing.
Googling this it seems that a common cause is browsers not allowing PUT requests but I'm not using a browser to test this - I'm using Fiddler. So there should be no problem there. I also think the correct settings are already in the web.config:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="UrlRoutingHandler" />
<remove name="MvcHttpHandler" />
<remove name="WebDAV" />
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>
<security>
<requestFiltering>
<verbs>
<add verb="PUT" allowed="true" />
</verbs>
</requestFiltering>
</security>
</system.webServer>
So what have I missed?
EDIT: This code works on a colleagues' machine. So it looks like my local setup of IIS as at fault. Still at a loss to explain what I need to change though - any ideas?
Cheers,
Matt
I had to remove the WebDav Module completely a stated in this blog post
<configuration>
<system.webServer>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules>
<remove name="WebDAVModule" />
</modules>
</system.webServer>
</configuration>
After much fruitless searching and blind alleys involving WebDAV I found the answer on another SO family site :)
https://serverfault.com/questions/93424/how-to-enable-put-and-delete-in-iis7
The configuration that worked for us was the following.
<system.webServer>
<modules runAllManagedModulesForAllRequests="false">
<remove name="UrlRoutingModule" />
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" preCondition="" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,POST,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
This is specific to extension-less URLs.
BTW the general recommendation is to set runAllManagedModulesForAllRequests = false.

Resources