asp.net-mvc-5

Strongly Typed RedirectToAction (Futures) using async Controllers

夙愿已清 提交于 2019-12-03 13:34:25
having this code it gives me a warning : Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call. public async Task<ActionResult> Details(Guid id) { var calendarEvent = await service.FindByIdAsync(id); if (calendarEvent == null) return RedirectToAction<CalendarController>(c => c.Index()); var model = new CalendarEventPresentation(calendarEvent); ViewData.Model = model; return View(); } public async Task<RedirectResult> Create(CalendarEventBindingModel binding) { var model =

Routing in ASP NET Web API - For different versions of an API

岁酱吖の 提交于 2019-12-03 13:33:38
问题 I am reading about Attribute Routing in Web API 2 from here The article says, Here are some other patterns that attribute routing makes easy. API versioning In this example, “/api/v1/products” would be routed to a different controller than “/api/v2/products”. /api/v1/products /api/v2/products How come? EDIT: I would do this in Normal Routing: public static class WebApiConfig { public static void Register(HttpConfiguration config) { config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate

ASP.NET MVC5: Want to update several items in Collection with model binding

戏子无情 提交于 2019-12-03 13:29:23
So I have a Collection of User objects, which should be mass-editable (edit many users at the same time). I'm saving the user input to the database using Entity Framework. The collection the controller method gets from the form is null. Why? Also, is the BindAttribute possible to use with collections like in my code? View: @model IEnumerable<Domain.User> @using (Html.BeginForm("UpdateUsers", "Users")) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) foreach (var item in Model) { @Html.HiddenFor(modelItem => item.Id) @Html.EditorFor(modelItem => item.FirstName) @Html

How to hold the cookies claims updated with MCV5/OWIN

浪子不回头ぞ 提交于 2019-12-03 13:23:30
We’re working on an OWIN MVC5 project. We use an own implementation of IUserStore<T> to integrate the user-management which is part of our companies framework. So far this works fine. We want to provide role membership and other security configuration through claims. I have seen (and quickly tested) the ways of either implementing IUserClaimStore<T> or of attaching a ClaimsIdentityFactory to the UserManager. In both scenarios, I see the issue that the claims are stored in the user’s cookie and when a role or another claim changes behind the web app (through another application which directly

Could not load file or assembly System.Web.Mvc or one of its dependencies

走远了吗. 提交于 2019-12-03 13:15:54
currently working on asp.net mvc5 (old mvc3 project). It builds just fine, but when I start the project but when I run the project I am facing the following error. Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Not sure how I can can fix this, any ideas? This is the Assembly Load Trace: === Pre-bind state information === LOG: DisplayName = System.Web.Mvc (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name:

One to many relationship between AspNetUsers (Identity) and a custom table

瘦欲@ 提交于 2019-12-03 12:57:33
问题 I'm desperate trying to create an One to Many relationship between AspNetUsers table of Identity 2.0 and a custom table called Map (One user can have many maps, but a map can only have one user) I've tryied mostly every solutions available in this website and also lost many days trying other soulutions found in the web. I'm stuck. Nothing seems to work for me. I'm new to MVC and EF so basically I think I need some sort of step-by-step guide. Can anyone please be very kind to provide me a

Communication between a WebJob and SignalR Hub

人盡茶涼 提交于 2019-12-03 12:56:49
I have the following scenario: I have an azure webjob (used to send mails) and I need to check the progress of the webjob in my web application. I am using SignalR to communicate with clients from my server. When I want to send an email, I push a message in the queue and the azure webjob does his job. The question is, how can I communicate the progress of the webjob to the client? Originally my idea was to push a message from the webjob, so the Hub could read it from the queue. Then, I would notify clients from the hub. However, I am not able to find a way to communicate the webjob and the hub

ASP.Net Identity 2 Reset password with SMS

核能气质少年 提交于 2019-12-03 12:55:05
I'm looking to send the user an SMS when reseting their password. I already have the facilities to send a SMS, I just need a guide on how to set it up with Identity 2.0. I can't seem to find any useful info online, the reference code itself isn't properly commented either. I want to generate a security code, send it to the user, he must then input it into a form and then be allowed to reset his/her password. Can anyone direct me to a guide/tutorial that explains this process? After digging in the identity source code i found an alternative token provider that can generate tokens similar to

How to implement a TokenProvider in ASP.NET Identity 1.1 nightly build?

五迷三道 提交于 2019-12-03 12:49:30
问题 I'm trying to implement password reset functionality with nightly build of ASP.NET Identity 1.1. There is a UserManager.GetPasswordResetToken method, but it throws an exception "No ITokenProvider is registered". Is there an built in token provider in ASP.NET Identity? If yes, how I can register it? If no, how I can implement one? Will be default Token Provider in the 1.1. release? And final question, is there an estimated 1.1 release date? 回答1: The default token provider implementation is

FormsAuthentication object obsolete [using MVC5]

纵然是瞬间 提交于 2019-12-03 12:14:43
I'm using the following code in an MVC5 site: [HttpPost] [ValidateAntiForgeryToken] public ActionResult Login(LoginModel loginModel) { if (ModelState.IsValid) { var authenticated = FormsAuthentication.Authenticate(loginModel.UserName, loginModel.Password); if (authenticated) { FormsAuthentication.SetAuthCookie(loginModel.UserName, true); return RedirectToAction("AdminPanel"); } ModelState.AddModelError("", "The username and password combination were incorrect"); } return View(loginModel); } Which throws up the following warning: System.Web.Security.FormsAuthentication.Authenticate(string,