【问题标题】:How to rewrite an url with parameters in ASP.NET/C# using web.config file如何使用 web.config 文件在 ASP.NET/C# 中重写带有参数的 url
【发布时间】:2023-04-06 01:12:01
【问题描述】:

我正在创建一个 asp.net Web 应用程序,我希望它可以在 url 中使用或不使用文件扩展名

举个例子让我们说这是我们的网址
localhost:8080/Login.aspx?something=1

我希望它在用户输入时工作
localhost:8080/Login?something=1

localhost:8080/Login.aspx?something=1

我做了这样的事情

<rewrite>
  <rules>
    <rule name="Rewrite with .aspx" stopProcessing="true">
      <match url="^(.+)(\?(.+)$|\#(.+)$|$)"/>
      <action type="Rewrite" url="{R:1}.aspx{R:2}"/>
    </rule>  
  </rules>
</rewrite>

有时这可行,但根本不行。它会影响页面中除地址栏中的 url 之外的所有其他 url 吗?我的网站中有 iframe。请帮助我。

谢谢

【问题讨论】:

    标签: c# asp.net url web-config rewrite


    【解决方案1】:

    如果你使用的是 Net 4.0,它有一个内置的 URL 路由功能 查看this文章

    我觉得对你有帮助

    【讨论】:

      猜你喜欢
      • 2013-01-08
      • 2016-05-23
      • 2014-08-12
      • 1970-01-01
      • 1970-01-01
      • 2014-04-05
      • 2021-02-01
      • 2011-09-05
      • 1970-01-01
      相关资源
      最近更新 更多