ASP.net MVC 5 Route with two parameter -
i want create web application 2 parameter. add code registerroutes function:
routes.maproute( "pageroute", "page/{pageid}/{pagename}", new { controller = "page", action = "index", pageid = "", pagename = "" } );
and add method in pagecontroller:
public actionresult index(int pageid,string pagename) { return view(); }
now when running application parameter
http://localhost:1196/page/4/pagename
application run when running parameter
http://localhost:1196/page/4/pagename.html
application return 404 error
http error 404.0 - not found resource looking has been removed, had name changed, or temporarily unavailable.
while add .html in parameter return 404 error. why?
because default html files not being served through mvc/iis.
your application looks physical file named pagename.html , cannot find there. hence - 404.
to make work, need setup iis catch requests files html extension , pass request mvc.
edit: here similar question op found solution switching "managed pipeline mode" "classic".
Comments
Post a Comment