重定向到Views文件夹内的html页面 [英] Redirect to an html page inside Views Folder

查看:96
本文介绍了重定向到Views文件夹内的html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们在Views文件夹中有 mypage.html (假设是ASP.NET MVC 3 Web应用程序)。

Say that we have mypage.html in Views Folder (Assuming an ASP.NET MVC 3 Web Application).

如何从操作重定向到 mypage.html 页面?

How to redirect to mypage.html page from an Action ?

推荐答案

您必须在路由中进行设置。

You would have to set this up in your routing.

在路由配置中:

routes.MapPageRoute("HtmlRoute","MyCustomUrl","Path/To/Your/mypage.html");

MapPageRoute与您在MVC中看到的常规MapRoute方法略有不同。它用于通过Web窗体进行路由,并且可以与MVC路由一起使用。这将映射到特定页面。这在 System.Web.dll

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

在您的控制器中:

return Redirect("MyCustomUrl");

这篇关于重定向到Views文件夹内的html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆