asp.net-mvc

Handle token timeout in Asp.Net MVC when using Azure AD

做~自己de王妃 提交于 2021-02-05 20:30:54
问题 This is more of a design/approach question... I think I'm missing something here. We're building an Asp.Net MVC 5 web application and securing it with Azure AD using the following scenario: https://azure.microsoft.com/en-us/documentation/articles/active-directory-authentication-scenarios/#web-browser-to-web-application https://github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect The token/cookie is an absolute expiry and expires after one hour. So what does that do for the

How to efficiently test if action is decorated with an attribute (AuthorizeAttribute)?

…衆ロ難τιáo~ 提交于 2021-02-05 20:28:37
问题 I'm using MVC and have a situation where in my OnActionExecuting() I need to determine if the Action method that is about to execute is decorated with an attribute, the AuthorizeAttribute in particular. I'm not asking if authorization succeeded/failed, instead I'm asking does the method require authorization. For non-mvc people filterContext.ActionDescriptor.ActionName is the method name I'm looking for. It is not, however, the currently executing method; rather, it is a method that will be

How to efficiently test if action is decorated with an attribute (AuthorizeAttribute)?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-05 20:27:40
问题 I'm using MVC and have a situation where in my OnActionExecuting() I need to determine if the Action method that is about to execute is decorated with an attribute, the AuthorizeAttribute in particular. I'm not asking if authorization succeeded/failed, instead I'm asking does the method require authorization. For non-mvc people filterContext.ActionDescriptor.ActionName is the method name I'm looking for. It is not, however, the currently executing method; rather, it is a method that will be

How to efficiently test if action is decorated with an attribute (AuthorizeAttribute)?

那年仲夏 提交于 2021-02-05 20:27:38
问题 I'm using MVC and have a situation where in my OnActionExecuting() I need to determine if the Action method that is about to execute is decorated with an attribute, the AuthorizeAttribute in particular. I'm not asking if authorization succeeded/failed, instead I'm asking does the method require authorization. For non-mvc people filterContext.ActionDescriptor.ActionName is the method name I'm looking for. It is not, however, the currently executing method; rather, it is a method that will be

Camel-Casing Issue with Web API Using JSON.Net

柔情痞子 提交于 2021-02-05 20:22:54
问题 I would like to return camel-cased JSON data using Web API. I inherited a mess of a project that uses whatever casing the previous programmer felt like using at the moment (seriously! all caps, lowercase, pascal-casing & camel-casing - take your pick!), so I can't use the trick of putting this in the WebApiConfig.cs file because it will break the existing API calls: // Enforce camel-casing for the JSON objects being returned from API calls. config.Formatters.OfType<JsonMediaTypeFormatter>()

Camel-Casing Issue with Web API Using JSON.Net

拈花ヽ惹草 提交于 2021-02-05 20:16:54
问题 I would like to return camel-cased JSON data using Web API. I inherited a mess of a project that uses whatever casing the previous programmer felt like using at the moment (seriously! all caps, lowercase, pascal-casing & camel-casing - take your pick!), so I can't use the trick of putting this in the WebApiConfig.cs file because it will break the existing API calls: // Enforce camel-casing for the JSON objects being returned from API calls. config.Formatters.OfType<JsonMediaTypeFormatter>()

Camel-Casing Issue with Web API Using JSON.Net

百般思念 提交于 2021-02-05 20:16:41
问题 I would like to return camel-cased JSON data using Web API. I inherited a mess of a project that uses whatever casing the previous programmer felt like using at the moment (seriously! all caps, lowercase, pascal-casing & camel-casing - take your pick!), so I can't use the trick of putting this in the WebApiConfig.cs file because it will break the existing API calls: // Enforce camel-casing for the JSON objects being returned from API calls. config.Formatters.OfType<JsonMediaTypeFormatter>()

Roles available with Windows Authentication

安稳与你 提交于 2021-02-05 17:41:28
问题 I'm trying to add Roles authentication to an Action in a Controller in an ASP.NET MVC application. The code looks something like this: [Authorize(Roles = "SomeRoleName")] public ActionResult Index() { bool inRole = User.IsInRole("Admin"); If I remove the Authorize attribute and put a breakpoint on the last line in that code sample, is there a way that I can inspect the objects and find out what roles are available? e.g. I call User.IsInRole("Admin) in the Immediate window and it will give me

Roles available with Windows Authentication

倾然丶 夕夏残阳落幕 提交于 2021-02-05 17:21:47
问题 I'm trying to add Roles authentication to an Action in a Controller in an ASP.NET MVC application. The code looks something like this: [Authorize(Roles = "SomeRoleName")] public ActionResult Index() { bool inRole = User.IsInRole("Admin"); If I remove the Authorize attribute and put a breakpoint on the last line in that code sample, is there a way that I can inspect the objects and find out what roles are available? e.g. I call User.IsInRole("Admin) in the Immediate window and it will give me

maxRequestLength for .Net 4.5.1 framework

▼魔方 西西 提交于 2021-02-05 16:44:41
问题 I want to convert a .Net framework 4.0 code into .Net framework 4.5. This is basically a file upload related code. Now I face some problems. What is the maximum value of maxRequestLength? I already add this line in my web.config file but it does not work and the Error code is 0x800700b7 <system.web> <httpRuntime maxRequestLength="102400" executionTimeout ="3600" /> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5"/> <authentication mode="Forms"> <forms