turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
559 stars 156 forks source link

Add support for OWIN and self hosted/non IIS hosted apps #156

Open jonnybee opened 10 years ago

jonnybee commented 10 years ago

Hope I18N project will support OWIN pipeline without dependencies on the "old" IIS hosting/pipeline.

This would also add support for self hosted apps.

suddenelfilio commented 9 years ago

I have an owin middleware that will work in IIS (httpcontextbase dependencies). To make this work in self hosted app i18n will need to be rewritten to not depend on the IIS pipeline classes.

I also had to fix the Flush method of the ResponseFilter class because in owin it's called twice which caused a nullreferenceexception on the bufferedstream being null

added a pull request #234

berniezhao commented 8 years ago

@suddenelfilio I'm using owin/WebApi2 with IIS, can you please enlighten me what changes I need to make to make i18n work? Thx.

turquoiseowl commented 8 years ago

I've not managed to look into OWIN support yet so hopefully others will chip in here, but my understanding from what's already been stated above is that OWIN doesn't support the ASP.NET pipeline upon which the i18n.LocalizingModule class depends.

The pipeline events we currently handle are BeginRequest, ReleaseRequestState and PostRequestHandlerExecute. Should there be a way of hooking into equivalent stages in OWIN's HTTP request handler then a modified version of i18n.LocalizingModule would need to integrate with that.

berniezhao commented 8 years ago

There are some structure challenges. OWIN uses middleware which uses .NET 4.5. It also uses Microsoft.Owin instead of System.Web. Therefore it seems like we need to move Pipeline folder out of i18n project, and make two dedicated i18n.IIS and i18n.Owin projects that implements pipeline separately, but still able to use the i18n classes like NuggetLocalizer.

Or maybe it makes more sense to make 3 NuGet packges. i18n.core, i18n.AspNet and i18n.Owin. :)

turquoiseowl commented 8 years ago

Yes, in addition to i18n.LocalizingModule, HttpContextBase would be an issue. I'm unclear on what the current state of affairs is with that class, in relation to ASP.NET old and new, WebApi, OWIN etc.......

berniezhao commented 8 years ago

@turquoiseowl I created a pull request to add support for Owin hosted in IIS. For self-hosted Owin we will need major structure changes. Let me know how do you want to handle the pull request. It doesn't break existing i18n assembly so either you can include it in your NuGet or if you want me to publish a separate NuGet that's ok too. Thanks.