1

I have some asp.net c# code that grabs the path name and uses it for various authorization and authentication tasks. In our web site project, this is what returns the path (with extension, for example: index.aspx?querystringparam1=3&qp2=4):

string strPath = HttpContext.Current.Request.RawUrl;

This used to return "index.aspx?querystringparam1=3&qp2=4".

However, in our work to convert to a web application project, that same line of code is now returning the url WITHOUT the extension: "index?querystringparam1=3&qp2=4".

How I can get the old behavior to return? It seems to be an IIS setting somewhere because going back to the website project on the same IIS instance does not revert to the old functionality.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Owen
  • 426
  • 5
  • 15
  • I just noticed that about half the time, the extension is there. The other half it is not. Very curious! – Owen Mar 19 '21 at 23:21
  • Hmmm. After more sleuthing, it turns out that it seems to be that IIS is returning a 301 permanent redirect from index.aspx to index (no extension). So far, have not located anywhere in our code that is doing this. Oh, and it started doing it once I "logged out" of the application. – Owen Mar 22 '21 at 16:23

1 Answers1

1

OK. I found the problem. Looks like Visual Studio, in its infinite wisdom, installs two packages that make up Microsoft Friendly Url (DynamicModule_Microsoft.AspNet.FriendlyUrls.FriendlyUrlsModule), which removes extensions from path files by sending a permanent redirect to the browser before even reaching the site code.

And, removing those NuGet Packages (there are two), solves the problem!

Owen
  • 426
  • 5
  • 15