Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Owin error with ASP.NET MVC application

I have an ASP.NET application that runs fine on my local machine. I just uploaded it to a server using web deploy. I'm getting the following error when I try to view the site:

The following errors occurred while attempting to load the app. - The OwinStartup attribute discovered in assembly 'Gators3' referencing startup type 'Gators3.Startup' conflicts with the attribute in assembly 'MyFirstProject2' referencing startup type 'MyFirstProject2.Startup' because they have the same FriendlyName ''. Remove or rename one of the attributes, or reference the desired type directly. To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config. To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.

I tried searching the entire solution for the string "MyFirstProject2" but did not come up with anything. The message gives a couple of suggestions, but none of them mean anything to me. I don't know how to "Remove or rename one of the attributes, or reference the desired type directly," and I don't see a place in the web.config to "add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config."

I found this, but am not quite sure how to implement it. I also did find [assembly: OwinStartupAttribute(typeof(Gators3.Startup))] in my Startup.cs, but not sure what the right thing to do there is either.

like image 666
abalter Avatar asked Jun 05 '15 23:06

abalter


People also ask

What is OWIN in ASP NET MVC?

OWIN is an interface between . NET web applications and web server. The main goal of the OWIN interface is to decouple the server and the applications. It acts as middleware. ASP.NET MVC, ASP.NET applications using middleware can interoperate with OWIN-based applications, servers, and middleware.

How do I disable OWIN startup discovery in web config?

To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web. config. To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.

How do I set up OWIN?

Create an ASP.NET Web App using OWIN Startup Add an OWIN startup class. In Visual Studio 2017 right-click the project and select Add Class. - In the Add New Item dialog box, enter OWIN in the search field, and change the name to Startup. cs, and then select Add.


4 Answers

The problem is that the Gators3.dll and MyFirstProject2.dll are in the same folder (I guess it is bin folder on your server) and both are using Owin middleware. If you do not need MyFirstProject2.dll then the easiest way would be to delete that assembly. If you need it, but without Owin - add following line to Web.config/app.config in your MyFirstProject2 project: <add key="owin:AutomaticAppStartup" value="False" />

If you need to use Owin for two projects configure friendly names for both of them.

  • Gators3 project:

Change Owin startup attribute to something like:

 attribute [assembly: OwinStartupAttribute("GatorsConfig", typeof(Gators3.Startup))]

And add following line to Web.config within appSettings section:

   <add key="owin:appStartup" value="GatorsConfig" /> 
  • MyFirstProject2 project:

Change Owin startup attribute to something like:

   attribute [assembly: OwinStartupAttribute("MyFirstProject2Config", typeof(MyFirstProject2.Startup))]

And add following line to Web.config within appSettings section:

   <add key="owin:appStartup" value="MyFirstProject2Config" />
like image 57
LaoR Avatar answered Oct 19 '22 20:10

LaoR


I had the same issue : removing everything in the bin folder and rebuilding the solution alone worked for me. But it could be combined with renaming your assembly attribute at the top of the startupclass, giving it a Firendly name which will help to differentiate both the startup files.

[assembly: OwinStartup("MyFriendlyNameForProject1",typeof(MyProject.Startup))]
like image 27
Nishanth Shaan Avatar answered Oct 19 '22 20:10

Nishanth Shaan


Clear your bin folder and obj folder.Rebuild the project again and run :)

like image 23
Sriman Saswat Suvankar Avatar answered Oct 19 '22 18:10

Sriman Saswat Suvankar


Delete anything that says 'MyFirstProject2' from your bin folder and rebuild the solution, It will work.

like image 6
Tino Jose Thannippara Avatar answered Oct 19 '22 20:10

Tino Jose Thannippara