Application_EndRequest的OWIN等价物是什么?

时间:2015-07-07 09:42:06

标签: asp.net owin

我正在将ASP.NET Web API申请迁移到OWIN。这不是为了使用OWIN部署。因此Global.asax将被移除。 Global.asax特别在Application_EndRequest中的OWIN事件处理程序中有一些代码应该由OWIN处理。

我已经阅读了一些关于using System; using System.Web.Http; using System.Web.Mvc; using System.Web.Optimization; using System.Web.Routing; using ProjectX.Web.AppStart; using ProjectY.Domain.Contracts; namespace ProjectX.UI { public class WebApiApplication : System.Web.HttpApplication { protected void Application_EndRequest(object sender, EventArgs e) { var unitOfWork = DependencyResolver.Current.GetService(typeof(IUnitOfWork)) as IUnitOfWork; unitOfWork.SaveChanges(); } } } namespace ProjectY.Domain.Contracts { public interface IUnitOfWork { void SaveChanges(); IRepository<T> GetRepository<T>() where T : class, IEntity, IHistory; IDbContext GetDbContext(); } } using ProjectY.Core.Repositories; using ProjectY.Domain.Contracts; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProjectY.Core.UnitOfWork { public class UnitOfWork : IUnitOfWork { public UnitOfWork(IProjectYDbContextFactory contextFactory) { _context = contextFactory.GetContext(); } public void SaveChanges() { if (_context == null) throw new ApplicationException("Something wrong has been happened. _context must not be null."); _context.SaveChanges(); } } } 的文章并搜索了互联网,但无法确定如何完成。谁能描述一下如何做到这一点?

我的环境:

  • Visual Studio 2015 RC
  • .Net Framework 4.5
  • Microsoft.AspNet.Cors.5.0.0
  • Microsoft.AspNet.WebApi.5.2.3
  • Microsoft.Owin.3.0.1
  • Owin.1.0

更新:这是当前代码的一些部分

   20            28      25     19     2     4             22
E   4  =E19*E20*E22  =E2*E4  0.001   860  0.80  =SUM(D22:D28)
D   4  =D19*D20*D22  =D2*D4  0.001   880  0.80  =SUM(C22:C28)
C   3  =C19*C20*C22  =C2*C4  0.001   900  0.90  =SUM(B22:B28)
F   3  =F19*F20*F22  =F2*F4  0.001   840  0.70  =SUM(E22:E28)
B   4  =B19*B20*B22  =B2*B4  0.001  1000  0.95              0
G   4  =G19*G20*G22  =G2*G4  0.002   800  0.60  =SUM(F22:F28)

0 个答案:

没有答案