asp.net-mvc-5

Custom Claims lost on Identity re validation

做~自己de王妃 提交于 2019-12-23 10:11:26
问题 I'm implementing Asp.NET MVC application with Identity 2.x Authentication and Authorization model. During LogIn process I add Custom Claims (not persisted in the DB!), deriving from data passed in the LogIn from, to the Identity and I can correctly access them later on, until the identity gets regenerated. [HttpPost] [AllowAnonymous] [ValidateHeaderAntiForgeryToken] [ActionName("LogIn")] public async Task<JsonResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid)

Enabling SSL Client Certificate Required for specific Controller or Action in Asp.Net MVC

我的未来我决定 提交于 2019-12-23 09:59:56
问题 Is there any MVC specific way to require an SSL Client Certificate for a specific Action or Controller, i.e very much the way RequireHttps or Authorize works, but for ClientCerts? I know about the trick where you create an empty folder in the site, a Controller with the same name as the folder and then set up a rule in web.config, but I don't want to do it this way, I am looking for an MVC solution if there is one. (Example of the web.config trick:) <location path="/ClientCert"> <system

Is it possible to disable authentication Filter on one action in an MVC 5 controller?

大憨熊 提交于 2019-12-23 09:29:34
问题 [AuthenticateUser] public class HomeController : Controller { // // GET: /Home/ public ActionResult Index() { return View(); } [AllowAnonymous] public ActionResult List() { return View(); } } How to remove authentication for action named as List? Please advise.... My Custom Filter coding as follow.. i have inherited the FilterAttribute call as well. Please advise regarding public class AuthenticateUserAttribute: FilterAttribute, IAuthenticationFilter { public void OnAuthentication

Could not determine which version of ASP.NET Web Pages to use

本秂侑毒 提交于 2019-12-23 09:19:35
问题 Weird goings on with my VS2013 projects. I recently upgraded one of my project branches from .NET 4.0 to 4.5.1 and used NuGet package manager to install MVC 5 with Razor so that I could have a WebForms/MVC hybrid. So far, it's working fine and I am able to use both WebForms and MVC. However, all of my other branches of the same project (the production branch for example) appear to be broken when they have not changed. When I run one of the other projects, I get: Could not determine which

Identity Server 3 - 401 on Ajax Calls instead of 302

谁说我不能喝 提交于 2019-12-23 09:17:28
问题 I have a web api / mvc hybrid app and I have configured it to use cookie authentication. This works fine for the mvc portion of the application. The web api does enforce the authorization, but instead of returning a 401 - Unauthorised it returns a 302 - Found and redirects to the login page. I would rather it returns a 401 . I have attempted to hook into the CookieAuthenticationProvider.OnApplyRedirect delegate, but this doesn't seem to be called. What have I missed? My current setup is below

ASP.NET Identity Two Factor not working - Cookie Issue?

无人久伴 提交于 2019-12-23 07:38:08
问题 Background: I have been using the Identity-Sample project provided by the Microsoft team here: I have integrated the Identity-Sample project & prerelease nuget packages into an existing project, that was previously using the latest stable version of Identity. Problem: When trying 2FA, inside the Account/SendCode method, there is a call to GetVerifiedUserIdAsync() , which is part of the Microsoft.AspNet.Identity.Owin.SignInManager class. (see the full code here) GetVerifiedUserIdAsync() is

Is it possible to change order of routes in routing table when using attribute routing?

限于喜欢 提交于 2019-12-23 06:59:04
问题 So, I'm switching an area over from using AreaRegistration to using Attribute Routing. I'm running into an issue which appears to be caused by the order in which routes are loaded into the routing table. I'd solved the issue in AreaRegistration by loading in the problematic route last, so that only if all other routes didn't match would that route be matched. With Attribute Routing, this doesn't appear to be possible. I have the Order parameter when creating a route, but this doesn't affect

How to run proration using ASP.NET MVC 5 and ASP.NET

你说的曾经没有我的故事 提交于 2019-12-23 05:49:05
问题 Here are two tables, amounttbl, amountId - amountValue requesttbl reqId - reqAmount - Rate - soldAmount, amountId Data: amounttbl amountId | amountValue ---------|------------ 1 | 5000 requesttbl reqId | reqAmount | Rate | soldAmount | amountId ------|-----------|------|------------|--------- 1| 2000| 12| 0| 1 2| 500| 12| 0| 1 3| 1000| 11| 0| 1 4| 500| 10| 0| 1 5| 1000| 10| 0| 1 For this, I have prepared an action that should sell the amount 5000, from a high rate and to a low rate, which

AJAX Call to MVC5 ActionResult

允我心安 提交于 2019-12-23 05:15:12
问题 I am trying to figure out what is wrong with the following code: $(".ReportScore").click(function () { $.ajax({ type: "GET", url: "/events/Tournaments/ReportScore", success: function() { location.reload(); }, error: function() { alert("The scores were not recorded"); } }); }); When I type the url in the bar, it works without problems, however when I try to do an ajax call I get 404 Page not found error. To clarify, when I click on the button I Get a popup saying "The scores were not recorded"

Setting the connection string of a DBContext in my repository class using Ninject

夙愿已清 提交于 2019-12-23 05:13:07
问题 I have an MVC 5 application that uses EF 6 and implements Repository pattern with dependency injection using the DI container Ninject. The connection string for the dbcontext is stored in the Web.config file which the EF Context properly finds. Everything works fine. Lately, I have a requirement that the connection to my DBContext need to be determined at runtime and connect to different databases (but with exactly the same structure). So, I need to change the sql connectionstring part from