ASP.NET MVC,授权后成立文化 [英] ASP.NET MVC, set culture after authorization

查看:128
本文介绍了ASP.NET MVC,授权后成立文化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们要设置的Thread.CurrentCulture


  • 之前的ASP.NET MVC模型绑定/验证运行(当然),

  • 用户已被授权(因为我们想从一个UserSettings表加载文化)

什么是正确的扩展点,我们应该去?

这是动作过滤器为时已晚,Global.asax中太早(用户尚未授权)。任何人只要有一个好主意?


解决方案

  

Global.asax中太早


Global.asax中有一个发生在请求生命周期,有些太早(的BeginRequest),有些太晚了(EndRequest)各点的事件,也许一个正好适合您的需求。

也许对 PostAuthorizeRequest 的处理程序,或者如果你想存储的东西,在会议上, PostAcquireRequestState 会怎么做?

We want to set the Thread.CurrentCulture

  • before the ASP.NET MVC model binder / validator runs (of course), but
  • after the user has been authorized (as we want to load the culture from a UserSettings table)

What's the correct extension point we should go for?

An action filter is too late, Global.asax is too early (user not authorized yet). Anyone with a good idea?

解决方案

Global.asax is too early

Global.asax has events that occur at various points in the request life cycle, some too early (BeginRequest), some too late (EndRequest), and maybe one that is just right for your requirement.

Maybe a handler for PostAuthorizeRequest, or if you want to store stuff in Session, PostAcquireRequestState would do?

这篇关于ASP.NET MVC,授权后成立文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆