在我的MVC3项目中,我存储了足球/足球/曲棍球/ ...运动游戏的得分预测.所以我的预测类的一个属性看起来像这样:
[Range(0, 15, ErrorMessage = "Can only be between 0 .. 15")]
[StringLength(2, ErrorMessage = "Max 2 digits")]
[Remote("PredictionOK", "Predict", ErrorMessage = "Prediction can only be a number in range 0 .. 15")]
public int? HomeTeamPrediction { get; set; }
Run Code Online (Sandbox Code Playgroud)
现在,int在我的情况下,我还需要更改数据类型的错误消息.使用了一些默认值 - "HomeTeamPrediction字段必须是数字.".需要找到一种方法来更改此错误消息.此验证消息似乎也对远程验证进行了预测.
我已尝试过[DataType]属性但这在system.componentmodel.dataannotations.datatype枚举中似乎不是普通数字.
有什么方法可以根据请求范围而不是应用程序范围为OpenIdConnectMessage设置RedirectUri属性?
我的应用程序服务于多个域(myapp.com,myapp.fr,..),并且基于域,它确定内容的默认语言.我需要在登录到IdP之后将用户带回到同一个域,因此我需要找到一种方法,如何通过在startup.cs中配置中间件选项来完成每个请求范围而不是应用范围设置RedirectUri.
我正在尝试将OpenId Connect集成到长期存在的Webforms应用程序中。我能够迁移该应用程序以使用OWIN,并且正在使用OpenIdConnectAuthenticationMiddleware对我的IdP提供程序进行身份验证。一切正常,直到需要构造从IdP获得的新身份并设置Cookie为止(我认为这没有发生)。
我的Startup.Configure方法的重要部分:
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/login.aspx"),
CookieManager = new SystemWebCookieManager() //custom cookie manager
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = "https://[development_domain]/core",
ClientId = "VDWeb",
ResponseType = "code id_token token",
Scope = "openid profile",
UseTokenLifetime = true,
SignInAsAuthenticationType = "Cookies",
Notifications = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenValidated = async n =>
{
var userInfo = await EndpointAndTokenHelper.CallUserInfoEndpoint(n.ProtocolMessage.AccessToken);
//now store Preferred name :
var prefNameClaim = new Claim(
Thinktecture.IdentityModel.Client.JwtClaimTypes.PreferredUserName,
userInfo.Value<string>("preferred_username"));
var myIdentity = new ClaimsIdentity(
n.AuthenticationTicket.Identity.AuthenticationType, …Run Code Online (Sandbox Code Playgroud) 是否有一些简单的方法来隐藏MVC3 WebGrid扩展的标头?就像是
var grid = new WebGrid(Model, canSort:false, canPage:false, showHeader:false);Run Code Online (Sandbox Code Playgroud)
我可以为标题设置css样式,这将导致标题不显示,但我宁愿通过代码完成此操作.
谢谢,
安东尼