单击按钮链接后直接进入链接页面,我可以进行加载屏幕吗?
<div class="col-md-3">
<a href="@Url.Action("PCApplicationRecord","Record")" class="btn btn-info btn-block">
<span class="fa fa-desktop"></span>
PC Application
</a>
</div>
Run Code Online (Sandbox Code Playgroud)
就我在互联网上看到的内容而言,加载屏幕或等待屏幕通常用于提交.
使用Microsoft ASP.NET Identity,如何获取已在控制器中进行身份验证的用户的Id?
我试图了解[AllowAnonymous]标签的工作原理.
我有以下方法
[HttpGet]
public ActionResult Add()
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
当我没有登录时,我可以打开此页面.我的印象是,只有将[AllowAnonymous]标记放在我应该能够做到的方法之上,才能做到这一点.我需要打开一个设置来使其工作吗?
如果安装了StructureMap.MVC5 nuget包,并更新了structuremap nuget包,则ControllerConvention类将要求您实现ScanTypes方法(来自更新的IRegistrationConvention接口).这是方法签名:
public void ScanTypes(TypeSet types, Registry registry)
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,
谢谢.
我尝试了很多搜索,然后尝试了其他选项,但似乎没有任何效果。
我正在使用ASP.net Identity 2.0,并且具有UpdateProfileViewModel。更新用户信息时,我想将UpdateProfileViewModel映射到ApplicationUser(即,身份模型)。但是我想保留这些值,我是从用户数据库中获得的。即用户名和电子邮件地址,不需要更改。
我试着做:
Mapper.CreateMap<UpdateProfileViewModel, ApplicationUser>()
.ForMember(dest => dest.Email, opt => opt.Ignore());
Run Code Online (Sandbox Code Playgroud)
但是映射后我仍然将Email设置为null:
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
user = Mapper.Map<UpdateProfileViewModel, ApplicationUser>(model);
Run Code Online (Sandbox Code Playgroud)
我也试过了,但是没有用:
public static IMappingExpression<TSource, TDestination> IgnoreAllNonExisting<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
{
var sourceType = typeof(TSource);
var destinationType = typeof(TDestination);
var existingMaps = Mapper.GetAllTypeMaps().First(x => x.SourceType.Equals(sourceType) && x.DestinationType.Equals(destinationType));
foreach (var property in existingMaps.GetUnmappedPropertyNames())
{
expression.ForMember(property, opt => opt.Ignore());
}
return expression;
}
Run Code Online (Sandbox Code Playgroud)
然后:
Mapper.CreateMap<UpdateProfileViewModel, ApplicationUser>()
.IgnoreAllNonExisting();
Run Code Online (Sandbox Code Playgroud) asp.net automapper asp.net-mvc-5 asp.net-identity asp.net-identity-2
为了解释的目的...假设我有一个由我的数据库中的表生成的表.
该表保存3条信息,FlightDate,Aircraft,Pre / Post.
那么,这背后的逻辑是,应该有一个飞行前和飞行后每天.
现在,为了清楚起见,我们说到目前为止这个表看起来像这样:
|Date| | |Aircraft| | |Pre / Post|
04/08/2016 | aircraft1 | Pre-Flight
04/08/2016 | aircraft3 | Pre-Flight
04/08/2016 | aircraft2 | Pre-Flight
04/08/2016 | aircraft3 | Post-Flight
04/08/2016 | aircraft1 | Post-Flight
04/08/2016 | aircraft2 | Post-Flight
Run Code Online (Sandbox Code Playgroud)
正如您所看到的那样,该表没有订单(可能是日期,但我刚刚做了这个).
现在我想要发生的是当页面加载显示这个表时,对于要由Aircraft它排序的表,它Pre / Post基于Date...
基本上我正在寻找的东西:
|Date| | |Aircraft| | |Pre / Post|
04/08/2016 | aircraft1 | Pre-Flight
04/08/2016 | aircraft1 | …Run Code Online (Sandbox Code Playgroud) 我试图在我的代码中做一些模拟,为此我想我会创建一个通用的方法,我可以发送de desiered类型,我想要返回.码:
private List<T> setSimulation<T>(Simulation simutlation, List<T> data)
{
var model = (List<TrainAnnouncement>)data;
return data;
}
Run Code Online (Sandbox Code Playgroud)
在某一点上,我需要在这个泛型方法中调用方法.所有这些方法都返回特定类的List.我的想法是我可以简单地将数据转换为desiered列表并调用我的方法.
可悲的是,这不起作用,我想知道为什么?以及如何正确实现这一点?
我需要能够像这样在测试中的代码中验证我的用户身份
var identity = new GenericIdentity("ausov@fsb.ru", "UserId");
Thread.CurrentPrincipal = new GenericPrincipal(identity, null);
Run Code Online (Sandbox Code Playgroud)
或者像这样
FormsAuthentication.SetAuthCookie(username, rememberMe);
Run Code Online (Sandbox Code Playgroud)
但这些方法不适用于asp net 5.
在MVC 5模板中实现Facebook登录,已添加了应用ID和密码。
最初登录失败,因为它返回null
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
// Crashes on this line
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
}
Run Code Online (Sandbox Code Playgroud)
搜索后遇到一个解决方案,该解决方案说用此替换现有的ExternalLoginCallback方法
[AllowAnonymous]
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var result = await AuthenticationManager.AuthenticateAsync(DefaultAuthenticationTypes.ExternalCookie);
if (result == null || result.Identity == null)
{
return RedirectToAction("Login");
}
var idClaim = result.Identity.FindFirst(ClaimTypes.NameIdentifier);
if (idClaim == null)
{
return RedirectToAction("Login");
}
var login = new UserLoginInfo(idClaim.Issuer, idClaim.Value);
var name = result.Identity.Name == null ? "" : …Run Code Online (Sandbox Code Playgroud) 我正在学习asp.net mvc 5.
我dropdownlistfor的工作很完美,并根据其价值展示了正确的领域.但问题是当页面第一次加载时显示所有字段..
问题是:我希望默认在页面首次加载时不显示任何内容.
我的cshtml:
<div class="form-group">
<div class="col-md-10">
@Html.DropDownListFor(m => m.PaymentMethod, ViewBag.PayTypeList as List<SelectListItem>, new { @class = "btn btn-primary btn-lg dropdown-toggle", @id = "PaymentId" })
<div id="PaypalButton">
<br/>
<script src="https://www.paypalobjects.com/api/button.js?"
data-merchant="braintree"
data-id="paypal-button"
data-button="checkout"
data-color="gold"
data-size="medium"
data-shape="pill"
data-button_disabled="true">
</script>
<!--data-button_type="paypal_submit"-->
</div>
<div id="EcheckForm">
<div class="form-group">
<div class="col-md-10">
@Html.TextBoxFor(m => m.VecInsNum, new { @class = "form-control input-lg", placeholder = "Vehicle Isurance Number", required = "required", tabindex = 18 })
@Html.ValidationMessageFor(m => m.VecInsNum, null, new { @class = …Run Code Online (Sandbox Code Playgroud) javascript asp.net-mvc jquery twitter-bootstrap asp.net-mvc-5
asp.net-mvc-5 ×10
c# ×5
asp.net ×3
asp.net-mvc ×3
.net ×1
automapper ×1
facebook ×1
generics ×1
javascript ×1
jquery ×1
linq ×1
nuget ×1
razor ×1
structuremap ×1