Dynamic routing handling in web config

两盒软妹~` 提交于 2021-02-20 04:45:05

问题


I have built up a project and deployed it in iis server and the web.config file looks like,

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="about" stopProcessing="true">
            <match url="^about$" />
            <action type="Rewrite" url="/about.html" />
        </rule>
        <rule name="contact" stopProcessing="true">
            <match url="^contact$" />
            <action type="Rewrite" url="/contact.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Folder structure.

This above code works fine if we navigate to https://your-site.com/contact or https://your-site.com/about .

Same way I also have dynamic routing like toolboxlinks/[toolboxlinks].html

Folder structure (On click the toolboxlinks folder from above screenshot, it results in)

For above scenario, I have included the rule like,

    <rule name="toolboxlinks" stopProcessing="true">
        <match url="^toolboxlinks/[toolboxlinks]$" />
        <action type="Rewrite" url="toolboxlinks/[toolboxlinks].html" />
    </rule> 

But it doesn't work and throws 404 error like,

I am entirely new to this scenario, So how to get rid of this error for dynamic routing?

来源:https://stackoverflow.com/questions/65958458/dynamic-routing-handling-in-web-config

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!