Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Adding Startup class to Web Api service

$
0
0

I created ODATA Web Api Service as described in http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/create-an-odata-v4-endpoint . Now I need my service to access ASP.NET Membership database, I looked how it was done in standard ASP.NET VS application - seems like Owin can help  so  now need to enable my web service with Owin. To add owin I first added the class

[assembly: OwinStartupAttribute(typeof(WebService.Startup))]

namespace WebService
{
    
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();
            WebApiConfig.Register(config);

            app.UseWebApi(config);
        }
    }
}

but its method Configuration is never called. I suspected that it could have something to do to the Global.asax with this content:

public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }

        public override void Init()
        {
            base.Init();
            
        }
    }

So I commented out the call to

            GlobalConfiguration.Configure(WebApiConfig.Register);

and now I am experiencing:

HTTP Error 500.0 - Internal Server Error without any specific details.

My Startup.Configuration is still not called so seems like that call in the line above is mandatory but I was hoping to substitute it with identical call from inside Startup.Configuration.

Can you tell me the right way to enable Owin (I assume Startup.Configuration should be called) in my existing web service?


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>