Is it possible to get HttpRedirect to work on an MVC site (from IIS Manager 7)?

Was just trying it out and searching about this, and didn't find anything.

Using IIS's HTTP Redirect functionality on ASP .NET sites works fine, however can't get it to work with an MVC application.

Thank you!

有帮助吗?

解决方案

As I could not get this to work (IIS 7 Manager's httpRedirect):

web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="true" destination="http://localhost/" exactDestination="true" httpResponseStatus="Permanent" />
    </system.webServer>
</configuration>

I'll just be using a line of Java Script at the top of the .cshtml:

<script type="text/javascript">window.location = "http://localhost/"</script>

I'd prefer using the httpRedirect, however this is the best workaround so far that does not require an application redeploy.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top