Redirect to an html page inside Views Folder

为君一笑 提交于 2019-12-23 19:03:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!