Allow POST for "static" files on the ASP.net development server

I had a problem when a service needs to send a POST to the root of my ASP.net application that runs on my instance of Visual Studio development (e.g. / myapp / for example). However, ASP.net complains that the "HTTP POST protocol used to access the path" / myapp / 'is not allowed.

How to enable recording on this path? Would URL rewriting be better (rewirte / myapp / to / myapp / Default.aspx)?

Thanks.

EDIT:

I just was able to get the job done by adding this to my Global.asax file:

void Application_BeginRequest(object sender, EventArgs e) { string p = Request.Path; if (p.Equals("/myapp/")) { var query = "?" + Request.QueryString.ToString(); if (query.Equals("?")) { query = ""; } Context.RewritePath("/myapp/Default.aspx" + query); } } 

But I have not tested very much, and I am curious if there is a better solution. This will also not work when deploying to IIS.

+4
source share
2 answers

It works now. This is a hard-coded rewrite in the Global.asax file:

 void Application_BeginRequest(object sender, EventArgs e) { string p = Request.Path; if (p.Equals("/myapp/")) { var query = "?" + Request.QueryString.ToString(); if (query.Equals("?")) { query = ""; } Context.RewritePath("/myapp/Default.aspx" + query); } } 

I would like to see a better solution.

+1
source

You can use the Url Rewrite module for IIS to rewrite the path.

The rule will look something like this (did not check it):

 <rewrite> <rules> <rule name="Rewrite to Default.aspx"> <match url="^myapp/+" /> <action type="Rewrite" url="/myapp/Default.aspx" appendQueryString="true" /> </rule> </rules> </rewrite> 
+1
source

Source: https://habr.com/ru/post/1345000/


All Articles