asp.net-web-api - web.config 中使用通配符的 Http 重定向不起作用

标签 asp.net-web-api visual-studio-2015 iis-express iis-8

我的需要是在 web.config 中告诉 IIS 忽略某些 URL 并向客户端发送 HttpRedirect。

为此,我在 web.config 中添加了以下魔法:

<system.webServer>
    <httpRedirect enabled="true" httpResponseStatus="Temporary" exactDestination="true"> 
        <add wildcard="*/iac*; " destination="http://someServer.smthg.be/iac$S$Q" />
    </httpRedirect>
</system.webServer>

当我尝试向“myserver/iac/john?doe=hello”发出请求时,我只收到 404 not found,而不是我预期的 302。

最佳答案

    <rewrite>
        <rules>
            <clear />
            <rule name="test" stopProcessing="true">
                <match url="^iac/(.*)" />
                <action type="Redirect" url="http://someServer.test.be/iac/{R:1}" appendQueryString="true" redirectType="Temporary" />
            </rule>
        </rules>
    </rewrite>

关于asp.net-web-api - web.config 中使用通配符的 Http 重定向不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33960261/

相关文章:

iis - 如何创建文件 applicationhost.config

azure - Azure 模拟器/IIS Express 和 SSL 客户端证书身份验证出现 web.config 错误

c# - 我可以依赖使用 Web API 的 CallContext 吗?

c# - 从模型验证中排除一个类型(例如 DbGeography)以避免 InsufficientExecutionStackException

ide - Web项目中右键单击文件夹中Visual Studio 2015中的慢上下文菜单

c++ - Visual Studio 2015,使用 2015 编译器

javascript - 使用 jQuery Ajax 将单个参数传递给 WebApi Controller

c# - 如何从 webforms 应用程序中使用 web API 服务?

visual-studio-2015 - VS 2015 更新 3 远程调试器下载

iis - 如何修复不会编译简单应用程序的 IIS Express?