Click here to Skip to main content
15,887,027 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Hash/Salt question Pin
Richard Deeming22-Aug-18 3:03
mveRichard Deeming22-Aug-18 3:03 
GeneralRe: Hash/Salt question Pin
Vincent Maverick Durano22-Aug-18 3:12
professionalVincent Maverick Durano22-Aug-18 3:12 
Questionhow to hold browsing path in fileupload control(i want to choose my choice folder) & How to get uploaded file path ,while click on show in folder(Show in Folder)? Pin
BNB-GOWD16-Aug-18 7:58
BNB-GOWD16-Aug-18 7:58 
AnswerRe: how to hold browsing path in fileupload control(i want to choose my choice folder) & How to get uploaded file path ,while click on show in folder(Show in Folder)? Pin
F-ES Sitecore16-Aug-18 22:17
professionalF-ES Sitecore16-Aug-18 22:17 
Question.Net Core Dependency Injection, How to architect it, do I need it? Email Queues. Pin
jkirkerx15-Aug-18 8:11
professionaljkirkerx15-Aug-18 8:11 
AnswerRe: .Net Core Dependency Injection, How to architect it, do I need it? Email Queues. Pin
F Margueirat23-Aug-18 8:18
F Margueirat23-Aug-18 8:18 
QuestionHow to manage a combined role + organization security in MVC? Pin
F Margueirat15-Aug-18 4:34
F Margueirat15-Aug-18 4:34 
AnswerRe: How to manage a combined role + organization security in MVC? Pin
jkirkerx15-Aug-18 8:35
professionaljkirkerx15-Aug-18 8:35 
I'm no expert at this by far. But I'll mention the HttpContext. It has a lifespan of one cycle and is stateless.
So I made a Attribute that you decorate the controller ActionResult with. It runs run before the ActionResult is fired, and passes everything downstream. Basically it's session free so you don't have to worry about restarts or what server you hit. I do remember this being a little buggy, in terms of having to erase the cookie a couple of times when exiting debug and starting again, but I think I fixed it.
[AdminCheck]
public IActionResult SomeEditor() 

The AdminCheck reads the cookie with special data in it, and if the user authenticates, it creates a new HttpContext.User using a GenericIdentity and GenericPrincipal

I wrote this for .Net Core
[AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class AdminCheckAttribute : ActionFilterAttribute, IActionFilter
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var controller = filterContext.Controller as Controller;
        var httpContext = controller.HttpContext;

        Model_Admin_Login pResult = SecurityCookies.CookieRead_Admin_Login(httpContext);
        if (pResult.AccountName != null)
        {<br />
            Model_Admin_Login model = new Model_Admin_Login();
            bool result = EF_Website_Users.AdminCheck_AccountName(pResult.AccountName, ref model);
            if (true == result)
            {
                // Program the HttpContext.Current
                // This will persist for the current cycle only
                String[] newRoles = { "Administrator" };
                GenericIdentity newIdentity = new GenericIdentity(pResult.AccountName);
                GenericPrincipal newPrincipal = new GenericPrincipal(newIdentity, newRoles);
                httpContext.User = newPrincipal;
                System.Threading.Thread.CurrentPrincipal = httpContext.User;

                // Store the Global ViewData to Show the Admin Menu or Not<br />
                controller.ViewData["Admin_Menu"] = true;
                controller.ViewData["Admin_UserID"] = model.ID;
                controller.ViewData["Admin_UserName"] = pResult.AccountName.ToLower();
                controller.ViewData["Admin_ImageUrl"] = model.Avatar.Url;
                controller.ViewData["Admin_ImageAlt"] = model.Avatar.Alt;
                controller.ViewData["Admin_Base64"] = model.Avatar.Data != null ? Convert.ToBase64String(model.Avatar.Data, 0, model.Avatar.Data.Length) : null;

            }
            else
            {
                controller.ViewData["Admin_Menu"] = false;
            }<br />
        }
        else
        {
            controller.ViewData["Admin_Menu"] = false;<br />
        }

        base.OnActionExecuting(filterContext);
    }        

}
If it ain't broke don't fix it
Discover my world at jkirkerx.com

GeneralRe: How to manage a combined role + organization security in MVC? Pin
F Margueirat20-Aug-18 7:00
F Margueirat20-Aug-18 7:00 
GeneralRe: How to manage a combined role + organization security in MVC? Pin
jkirkerx20-Aug-18 7:23
professionaljkirkerx20-Aug-18 7:23 
QuestionBrowser Security Pin
saurabh.15in14-Aug-18 3:39
saurabh.15in14-Aug-18 3:39 
AnswerRe: Browser Security Pin
Richard Deeming14-Aug-18 4:15
mveRichard Deeming14-Aug-18 4:15 
GeneralRe: Browser Security Pin
saurabh.15in15-Aug-18 21:28
saurabh.15in15-Aug-18 21:28 
QuestionI am getting the following error in my Production Server: Error Message: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state. Pin
indian14313-Aug-18 7:59
indian14313-Aug-18 7:59 
AnswerRe: I am getting the following error in my Production Server: Error Message: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state. Pin
Richard Deeming13-Aug-18 8:10
mveRichard Deeming13-Aug-18 8:10 
QuestionAsp.Net Core 2.1 with Angular 6 inside, Angular 6 service adding record using .net controller, what to return?, and use of MongoDB with auto increment Pin
jkirkerx13-Aug-18 7:58
professionaljkirkerx13-Aug-18 7:58 
Answer[Solved the CreatedAtRoute] Pin
jkirkerx13-Aug-18 8:43
professionaljkirkerx13-Aug-18 8:43 
QuestionUsing Elmah for my ASP.Net MVC application Pin
indian14312-Aug-18 22:08
indian14312-Aug-18 22:08 
QuestionI am creating graph chart line chart bar chart in asp.net web form. Pin
Member 1389651512-Aug-18 20:04
Member 1389651512-Aug-18 20:04 
AnswerRe: I am creating graph chart line chart bar chart in asp.net web form. Pin
Richard MacCutchan12-Aug-18 21:01
mveRichard MacCutchan12-Aug-18 21:01 
QuestionThe remote name could not be resolved Pin
Member 102909889-Aug-18 1:10
Member 102909889-Aug-18 1:10 
AnswerRe: The remote name could not be resolved Pin
Richard Deeming9-Aug-18 1:42
mveRichard Deeming9-Aug-18 1:42 
AnswerRe: The remote name could not be resolved Pin
Nathan Minier9-Aug-18 2:23
professionalNathan Minier9-Aug-18 2:23 
QuestionSetting onblur, onkeyup and onkeydown for @Html.Kendo().TextBoxFor using HtmlAttributes Pin
indian1438-Aug-18 14:34
indian1438-Aug-18 14:34 
AnswerRe: Setting onblur, onkeyup and onkeydown for @Html.Kendo().TextBoxFor using HtmlAttributes Pin
jkirkerx13-Aug-18 8:10
professionaljkirkerx13-Aug-18 8:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.