问题
Say that we have mypage.html
in Views Folder (Assuming an ASP.NET MVC 3 Web Application).
How to redirect to mypage.html
page from an Action ?
回答1:
You would have to set this up in your routing.
In your routes configuration:
routes.MapPageRoute("HtmlRoute","MyCustomUrl","Path/To/Your/mypage.html");
MapPageRoute is slightly different than the regular MapRoute method you see in MVC. It is used for routing with Web Forms and will work in conjunction with MVC routing. This will map to a specific page. This is in namespace System.Web.Routing
in System.Web.dll
and
In your Controller:
return Redirect("MyCustomUrl");
回答2:
I'm assuming you're not using routing, so here is what you could do at the end of an Action:
return Redirect("urlToHtmlPage");
来源:https://stackoverflow.com/questions/13862805/redirect-to-an-html-page-inside-views-folder