Hasindu Lanka
Hasindu Lanka

Reputation: 79

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?

Upvotes: 2

Views: 819

Answers (2)

manuc66
manuc66

Reputation: 2839

You can add a handler in Web.config:

 <handlers>
        <add name="CustomHandler" path="handler" verb="GET" type="AppCode.CustomHandler" preCondition="integratedMode"/>
  </handlers>

Upvotes: 1

VDWWD
VDWWD

Reputation: 35514

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>

Upvotes: 1

Related Questions