路线WWW链接非www链接.NET MVC [英] Route www link to non-www link in .net mvc

查看:115
本文介绍了路线WWW链接非www链接.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎与内置在友好路库中.NET MVC,那就让我们做这样的事情。

It seems with the built in friendly routing library in .NET MVC, it would allow us to do something like this.

在情况下,它并不清楚我想与内置在.NET MVC的东西,我想一个url以www开始被自动重定向到使用MVC框架非www的网址。

In case it's not obvious what I want to with the built in stuff in .NET MVC, I want to a url starting with www to be automatically redirected to a non-www url using the MVC framework.

推荐答案

有许多方法可以做到301从WWW到不带www重定向。我preFER保持这种重定向逻辑的(即我的应用程序)在某些项目中,ASP.NET水平,但有些则需要性能更好的东西,像IIS7 URL重写。

There are a number of ways to do the 301 redirect from the www to the not-www. I prefer to keep this redirection logic at the ASP.NET level (i.e. in my app) in some projects, but others require better performing things, like IIS7 url rewriting.

这是在ASP.NET论坛讨论,我选择使用WwwFilter每个控制器。这工作对我来说,没有问题。

It was discussed on the ASP.NET forums and I chose to use a WwwFilter on each controller. This has worked for me, no issues.

这篇关于路线WWW链接非www链接.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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