I try to do the following in my web.config:
<appSettings> <add key="owin:AutomaticAppStartup" value="false" /> <add key="owin:appStartup" value="MyNamespace.MyStartupClass" /> </appSettings>
If I understand this documentation correctly automatic startup detection should be disabled. So I do not require a startup attribute.
Unfortunately it looks like OWIN does not start. (I see this because I get the error: HTTP Error 403.14 - Forbidden. I use a controller to handle requests to the index file.)
if I use <add key="owin:AutomaticAppStartup" value="true" /> and add the startup attribute [assembly: OwinStartup(typeof(MyStartupClass))] then the application does startup as expected.
So the question is why? What can I do to resolve the issue?
I am using OWIN 3.0.0.0
Update:
This is how my startup class looks like (minified version with relevant parts):
using System.Web.Http;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using Owin;
using MyOtherNamespace;
namespace MyNamespace
{
public class MyOnlineStartup : MyOtherStartup
{
public new void Configuration(IAppBuilder app)
{
base.Configuration(app); //Call base method! This is important because otherwise ther serilization will not be correct
HttpConfiguration config = CreateRouting();
config.Routes.MapHttpRoute("exampleAppNone", "", new { controller = "MyIndex" }, null, null);
config.Routes.MapHttpRoute("exampleAppIndex", "index.html", new { controller = "MyIndex" }, null, null);
app.UseWebApi(config); // Use the WebAPI technology.
}
}
}
it derives from
using System.Linq;
using System.Web.Http;
using Microsoft.AspNet.SignalR;
using Newtonsoft.Json;
using Owin;
namespace MyOtherNamespace
{
public class MyOtherStartup
{
protected static HttpConfiguration CreateMyRouting()
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
"myIndex",
"my/",
new
{
controller = "MyIndex"
},
null,
null
);
config.Routes.MapHttpRoute(
"myIndex2",
"my/index.html",
new
{
controller = "MyIndex"
},
null,
null
);
var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
config.Formatters.JsonFormatter.SerializerSettings.TypeNameHandling = TypeNameHandling.Auto
return config;
}
public void Configuration(IAppBuilder app)
{
JsonSerializer serializer = Serialization.ClientJsonSerializer();
serializer.ContractResolver = new MySerializationContractResolver(false);
GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);
app.MapSignalR("/" + MyRequestHandler.MySignalRPath, new HubConfiguration());
}
}
}
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Simply remove this line of code in web.config file:
<add key="owin:AutomaticAppStartup" value="false" />
Your web.config file now must look like this:
<appSettings>
<add key="owin:appStartup" value="MyNamespace.MyStartupClass" />
</appSettings>
By adding just owin:appStartup key you don’t need startup attribute.
Method 2
Sometimes if you rename your project name then also you can get this error. Please make sure to rename your assembly info & please check your project properties also. Right Click on your Project => Go To Properties => Verify your assembly name and project name.
For me this solved my issue with OWIN library.
Project Properties Assembly Name Change
Method 3
Similar issue but had to do a little more to reach a solution.
after making the changes, even restart won’t solve the issue sometimes, you need to delete and add the server files to take effect.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0