One of the projects I’m working on is in MVC 4. The team decides to upgrade the project to MVC 5. The process is fairly simple. Go to Nuget Package Manager and upgrade MVC to MVC 5. The project then still builds successfully but when navigating to the site, I receive the following error.
After some research, the cause of error is that OWIN startup discovery in MVC 5 looks for a file named StartUp.cs (name convention) or a class with the OwinStartup attribute to wire up MVC, services, EF, etc. but MVC 4 does not have this class nor upgrading to MVC 5 will create this class automatically.
There are two solutions to fix up this error.
Add a StartUp.cs file
This is a more popular choice to fix the issue as it supports the default behaviour of MVC 5.
- To add an OWIN startup class, right click the project and select Add -> Add new item
- Enter OWIN in the search box, select OWIN Startup class, and name it StartUp.cs and then click Add
You then will have to migrate all your configurations from the global.asax.cs.
If you don’t want to name it StartUp.cs, you could use the following two methods:
- Use the OwinStartup attribute for your class.
[assembly: OwinStartup(typeof(DemoApplication.DemoStartup))] namespace DemoApplication { public class DemoStartup { public void Configuration(IAppBuilder app) { } } }
- Use the owin:appStartup appSetting in the project web.config. This setting will override the naming convention.
<appSettings> <add key="owin:appStartup" value="DemoApplication.DemoStartup" /> </appSettings>
Disable OWIN start up discovery
This is the less popular solution but it is a quick fix and I haven’t figured out any other effects when disabling OWIN start up discovery.
To disable OWIN start up discovery, just simply add the following appSetting to your web.config file
<appSettings> <add key="owin:AutomaticAppStartup" value="false" /> </appSettings>
Wow! This could be one particular of the most beneficial blogs We have ever arrive across on this subject. Actually Excellent. I am also a specialist in this topic so I can understand your hard work.
Yes it is though there are many things I don’t like about WordPress so if I find something better I would switch.
I was able to find good info from your articles.
At this time it appears like WordPress is the top blogging platform available right now.
(from what I’ve read) Is that what you’re using on your blog?