Search code examples
c#asp.neturlurl-routingashx

Access ASHX from URL without .ashx extension


I have a Web handler in an ASP.Net project. I want to access it from the URL.

Yes, I can do it like http://mywebsite.com/handler.ashx?id=35157 It works fine.

But the problem is, I'm accessing it from some Arduino devices. Their libraries do not support that kind of URLs.

They support http://mywebsite.com/handler?id=35157 like URLs.

How can I access the web handler from URLs like http://mywebsite.com/handler?id=35157,device=DF,Msg=OK

Without the ASHX extension in it?


Solution

  • You can always use an IIS rewrite rule.

    <rule name="Remove ASHX Extension" stopProcessing="true">
      <match url="^handler(.*)$" />
      <action type="Rewrite" url="handler.ashx{R:1}" />
    </rule>