Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Owin hosted on IIS doesn't capture URLs with Dot "."

I have an owin project I am hosting it using Microsoft.Owin.Host.SystemWeb. It works fine but if I have a Dot in the url it fails and I get a 404. For example

localhost:4070/cdn/aa works

but

localhost:4070/cdn/a.a doesn't work

I have also done the following changes in

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">    
  </modules>

I am sure this setting solves the problem in plain asp.net web api but I am having this issue with Owin.

update

I have tried this with owin host it is similar behavior, the calls with "." are not routed to webapi.

I can understand the behavior that when there is a dot in the last part of the url the framework thinks it is a file and tries to handle it but my problem is that I would like to handle these urls in my normal pipeline. I am actually writing a proxy for Microsoft cdn and the files are generated on run time using another server.

like image 665
Ovais Avatar asked Jun 20 '14 13:06

Ovais


People also ask

Can we host Owin in IIS?

Hosting of OWIN in IISUse the following procedure. Step 1: Open the Visual Studio and create the "New Project". Step 2: Create the new ASP.NET Web Application and enter the name for the application. Step 3: Select the Empty Project Template to create the application.

What is Microsoft Owin host SystemWeb?

SystemWeb. OWIN server that enables OWIN-based applications to run on IIS using the ASP.NET request pipeline.

What is OwinStartup attribute?

The OwinStartup attribute specifies the production startup class is run. Create another OWIN Startup class and name it TestStartup .


1 Answers

This config worked for me:

<system.webServer>
  <handlers>
    <add name="OWIN" path="*" verb="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" />
  </handlers>
</system.webServer>

In odred to get file path from "public/" folder and put it in response I ended up with this:

string filePath = System.Web.Hosting.HostingEnvironment.MapPath("~/public" + context.Request.Path);
like image 138
Alexander Shutau Avatar answered Oct 10 '22 01:10

Alexander Shutau