owin

OWIN interferes with log4net

自闭症网瘾萝莉.ら 提交于 2019-12-05 15:12:24
In my application, I've got the following logging strategy/appenders: DebugAppender : If the root level is DEBUG, write every message that matches DEBUG to the default trace listener output ConsoleAppender : If the application mode (global context property) is 'console', write every message above WARN to the console ouput EventLogAppender : If the application mode (global context property) is 'service', write every message above ERRROR to the console output RollingFileAppender : Write every message above INFO to a rolling flat file This works very well throughout the whole application, until

Simple Injector and default AccountContoller dependency issue

痴心易碎 提交于 2019-12-05 14:38:19
I have problem with Simple Injector in my Web Api project. I user default AccountController generated by VS. public AccountController(ApplicationUserManager userManager, ISecureDataFormat<AuthenticationTicket> accessTokenFormat) In my configuration file I register: var container = new Container(); // This is an extension method from the integration package. container.RegisterWebApiFilterProvider(config); container.RegisterWebApiControllers(config); container.Register<IInitializeService, InitializeService>(); container.Register<IFolderRepository, FolderRepository>(); container.Register

Make an HTTP POST authentication basic request using Javascript

ⅰ亾dé卋堺 提交于 2019-12-05 14:01:55
问题 I want to use JavaScript to perform a POST request using the common "Authorization: Basic" method. The server hosts an OWIN C# App and on successful authentication it should give me a token in JSON format. This is the wireshark equivalent of what I want to accomplish using plain Javascript: POST /connect/token HTTP/1.1 Authorization: Basic c2lsaWNvbjpGNjIxRjQ3MC05NzMxLTRBMjUtODBFRi02N0E2RjdDNUY0Qjg= Content-Type: application/x-www-form-urlencoded Host: localhost:44333 Content-Length: 40

Run a .Net MVC5 application on Mono

半城伤御伤魂 提交于 2019-12-05 12:06:56
I am developing an .Net 4.5.1 MVC5 application in Visual Studio 2013 on Windows. Now I want to know, if it is possible to run this application on Linux ( Ubuntu 12.04 )? Would it be possible to use OWIN? Owin can be run self hosted which means no IIS which is a start see here Use OWIN to Self-Host ASP.NET Web API Then to also help see this post about deploying to a mono instance on heroku Running OWIN/Katana apps on Heroku 来源: https://stackoverflow.com/questions/21455600/run-a-net-mvc5-application-on-mono

OWIN Authentication and Custom Response

风格不统一 提交于 2019-12-05 11:18:01
I create a custom BasicAuthenticationMiddleware that use a BasicAuthenticationHandler to Authenticate requests from client to WebAPI. The BasicAuthenticationHandler derives from the AuthenticationHandler< TOptions > base class. Everything works fine and I implemented the AuthenticateCoreAsync where the logic to authenticate happens ApplyChallengeResponseAsync where the logic, in case of not authenticated requests, sends the WWW-Authenticate header to the client. What I would like to achieve now is to set a Custom Body in the Response (IOwinResponse, inside the ApplyChallengeResponseAsync, with

ASP.NET Classic OWIN StartUp ConfigureServices not called

送分小仙女□ 提交于 2019-12-05 10:48:30
I am writing a ASP.NET Classic WebAPI application. I have implemented the OWIN StartUp class, and the Caonfiguration method is executed, however, the ConfigureServices method does not get executed. I know this works for DotNetCore. using Microsoft.Extensions.DependencyInjection; using Microsoft.Owin; using Owin; [assembly: OwinStartup(typeof(ClassicWebApi.Startup))] namespace ClassicWebApi { public class Startup { public void ConfigureServices(IServiceCollection services) { //CODE IS NOT EXECUTED } public void Configuration(IAppBuilder app) { //CODE IS EXECUTED } } } Is this only a feature of

How do I ask Owin/Katana to write headers to the output stream?

时间秒杀一切 提交于 2019-12-05 10:28:37
When I write to the response, Katana skips sending out the Elapsed-Time response header. How can I have it set the headers for me before I write to the stream for the first time? Middleware #1 public override async Task Invoke(IOwinContext context) { var stopwatch = new Stopwatch(); stopwatch.Start(); await Next.Invoke(context); stopwatch.Stop(); context.Response.Headers.Add("Elapsed-Time", new[] {stopwatch.ElapsedMilliseconds.ToString()}); } Middleware #2 public override async Task Invoke(IOwinContext context) { await context.Response.WriteAsync("test"); } After some research, the answer is

Why does my site redirect back to the Login screen when I click an external provider button?

纵饮孤独 提交于 2019-12-05 10:08:27
I'm upgrading an ASP.Net MVC4 site to MVC5, and implementing the new OWIN Authentication methods in the process. I've copied over the action methods from the Account controller on a blank MVC5 project. The problem is, when I click an external provider button (e.g. Google) I just get redirected back to the login page again. The second time I click it, I do get taken to the Google account page, but then the browser gets redirected to the Account/External login page. What's going on? Check the <authentication> element in your web.config file. It is probably still saying <authentication mode=

Why does the order of auth middleware declaration matter in Owin Startup class?

这一生的挚爱 提交于 2019-12-05 09:45:10
I read some examples( 1 , 2 , 3 , 4 ) about setting up authentication in the owin pipeline when using web api and the examples declare the authentication middleware as the first middleware in the Configuration method but doesn't tell why it needs to be first. In this question the auther had the webapi middleware attached before the authentication middleware and then the authentication didn't work correctly. When the auther moved it to the top of the method then everything work as expected.. Does anyone know why the authentication middleware needs to be added as the first middleware in the

Owin on IIS web requests hang indefinitely

南楼画角 提交于 2019-12-05 09:25:47
We are running an Owin applications on IIS 8.5 on Win 2012 R2 behind a loadbalancer. One some occations, requests to certain URLs hang indefinitely. If the user selects cancel in the browser, and reloads the page, everything is OK and the server responds quickly. In IIS manager, we can see the requests hanging: The hang seems to occur inside the Owin pipeline. We are running .NET 4.5.2 and the latest Owin packages. Here's the code for the /api/whoami endpoint: [Authorize] public class WhoAmIController : ApiController { [Route("whoami")] [HttpGet] public IHttpActionResult Whoami() { return Json