我们曾经使用ISAPI Re-Write(实际上它仍然在我们的服务器上),尽管它不能与ASP.Net MVC一起工作(与euxd-get-param有点关系)。
我们需要一种可行的方式来实现简单的301重定向,当我们更改网站结构、上传新网站等时。有什么建议吗?
好的,我想重定向/SomeFolder/SomePage.HTML吗?参数1=X到/新页面/X
我们怎么能做到这一点?
我们曾经使用ISAPI Re-Write(实际上它仍然在我们的服务器上),尽管它不能与ASP.Net MVC一起工作(与euxd-get-param有点关系)。
我们需要一种可行的方式来实现简单的301重定向,当我们更改网站结构、上传新网站等时。有什么建议吗?
好的,我想重定向/SomeFolder/SomePage.HTML吗?参数1=X到/新页面/X
我们怎么能做到这一点?
如果您正在使用IIS7,我建议您使用官方IIS7 URL重写模块。
在MVC 3中,有三种新的重定向方法可以在控制器中用于永久重定向(产生301);与MVC 2重定向产生的302(临时重定向)相反。
public ActionResult OldAction() { return RedirectPermanent(urlname); }
要执行从非MVC页面到MVC控制器操作的重定向,最好使用UrlRewriteing.net或类似的方法,使用HttpModule处理每个请求并将其发送到特定位置。
示例:将/faq.asp的请求重定向到/faq:
<add name="faq.asp" virtualUrl="^~/faq.asp([?#].*)?$"
destinationUrl="~/faq"
redirect="Application"
redirectMode="Permanent"
ignoreCase="true" />
将为UrlRewriteing.Net提供动力的HttpModule添加到Web.config时,请确保在由ASP.Net自动定义的UrlRoutingModule之前定义它。否则,ASP.NET将尝试通过将您的请求映射到文件或控制器来处理您的请求,因此您可能会遇到一些意外问题。
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
我只是博客文章介绍了一个使用ASP.NET MVC和XML文件来存储301重定向映射的简单解决方案。
然而,根据Nathan Taylor的回答,如果您需要进行基于Regex的映射,我建议使用UrlRewriteing.Net。
实现自定义ActionResult。示例:http://www.stum.de/2008/10/22/permanentredirectresult/
In my webpages I have references to js and images as such: "../../Content/Images/"Filename" In my code if I reference a file as above, it doesnt work so i have to write: "c:/miscfiles/"filename" 1-...
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
I m looking for best practices here. Sorry. I know it s subjective, but there are a lot of smart people here, so there ought to be some "very good" ways of doing this. I have a custom object called ...
I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...
i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...
For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!