c# - MVC 404 For Simple Route -


i specifying custom route , action. doing wrong? getting 404 error. set similar example: http://www.codeproject.com/articles/190267/controllers-and-routers-in-asp-net-mvc

url:

http://localhost:14133/scansummary/mywebsite.com 

route:

routes.maproute(     "scansummary",     "scansummary/{domain}",     new { controller = "scansummary", action = "get" }     ); 

controller:

public class scansummarycontroller : controller {     public actionresult get(string domain)     {         return view();     } } 

because of .com extension, iis thinks file on disk , attempts serve directly instead of going through pipeline.

one way fix issue running managed modules requests:

<system.webserver>     <modules runallmanagedmodulesforallrequests="true" />     ... </system.webserver> 

another (and imho better way) explicitly map mvc handler endpoint:

<system.webserver>     <modules runallmanagedmodulesforallrequests="false" />     <handlers>         ...         <add              name="svansummaryhandler"              path="scansummary/*"              verb="get,head,post"              type="system.web.handlers.transferrequesthandler"             precondition="integratedmode,runtimeversionv4.0" />     </handlers> 

also recommend reading following blog post better understand gotchas awaiting if intend passing arbitrary characters in path portion of url: http://www.hanselman.com/blog/experimentsinwackinessallowingpercentsanglebracketsandothernaughtythingsintheaspnetiisrequesturl.aspx

and follow scott hanselmann suggests:

after effort crazy stuff in request path, it's worth mentioning keeping values part of query string (remember way @ beginning of post?) easier, cleaner, more flexible, , more secure.

oh , make things funnier may take @ blog post: http://bitquabit.com/post/zombie-operating-systems-and-aspnet-mvc/

after reading did start using query strings? hope did.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -