简体   繁体   中英

Call handler without specifying ashx file on URL?

I have a handler called HandlerGeoserver

If I call localhost:55000/HandlerGeoserver.ashx on runtime everything works fine. I need to remove the HandlerGeoserver.ashx text from the URL, and make the request to be handled by the handler.

localhost:55000/ fires the HandlerGeoserver.ashx

Is this possible?

  • If not, an option I considered is to set via web.config to route / routes to handlerGeoserver.ashx , but don't know if this is possible.

  • Another option I considered was to combine the handler with webapi, so that when calling a route from the api ( localhost:55000/ ), the controller redirects the call to the handler. Do you think this could be a good approximation?

Finally solved creating a rewrite rule on my web.config as following:

<rewrite>
   <rules>
      <rule>
         <match url="/" />
         <action type="Rewrite" url="HandlerGeoserver.ashx" />
      </rule>
   </rules>
</rewrite>

It is the simplest and most effective solution I found.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM