1
votes

I have been trying to create a web api 2 that is secure with individual account.

So I can easily create WebApi2 with individual account, see link below http://www.asp.net/vnext/overview/authentication/individual-accounts-in-aspnet-web-api

And Self hosting is easy to do. http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api

But I cannot figure out how to combine the solutions.

Far as I got was adding a console app to a webapi2. Which seems to run. But whenever I try and get the access token it returns

An unhandled exception of type 'System.Net.WebException' occurred in System.dll Additional information: The remote server returned an error: (500) Internal Server Error.

If anyone knows of a solution that would be great. Thanks

1

1 Answers

0
votes

This post is way old, but to anyone else who is having this issue and finds this question, I was able to get past the 500 Error by adding app.UseWebApi(config); after setting up config, as mentioned in this post:

http://odetocode.com/blogs/scott/archive/2013/07/24/self-hosting-webapi-with-katana.aspx

HOWEVER, I'm now getting a 401, unauthorized request for all of my requests, even though I have a valid token and I'm sending it the same way I did that worked in the non-self-hosted WebApi2 app. but I'm one step closer anyways.