Adding ASP.NET MVC5 Identity Authentication to an existing project

I have seen lots of similar pages on the web, but most of them use a new project instead of an existing one, or don’t have the necessary features. So, I have an existing MVC 5 project and want to integrate ASP.NET MVC5 Identity with log in, email confirmation and password reset features. In addition … Read more

include antiforgerytoken in ajax post ASP.NET MVC

I am having trouble with the AntiForgeryToken with ajax. I’m using ASP.NET MVC 3. I tried the solution in jQuery Ajax calls and the Html.AntiForgeryToken(). Using that solution, the token is now being passed: var data = { … } // with token, key is ‘__RequestVerificationToken’ $.ajax({ type: “POST”, data: data, datatype: “json”, traditional: true, … Read more

How serious is this new ASP.NET security vulnerability and how can I workaround it?

I’ve just read on the net about a newly discovered security vulnerability in ASP.NET. You can read the details here. The problem lies in the way that ASP.NET implements the AES encryption algorithm to protect the integrity of the cookies these applications generate to store information during user sessions. This is a bit vague, but … Read more

Why is access to the path denied?

I am having a problem where I am trying to delete my file but I get an exception. if (result == “Success”) { if (FileUpload.HasFile) { try { File.Delete(Request.PhysicalApplicationPath + app_settings.login_images + txtUploadStatus.Text); string filename = Path.GetFileName(btnFileUpload.FileName); btnFileUpload.SaveAs(Request.PhysicalApplicationPath + app_settings.login_images + filename); } catch (Exception ex) { Message(ex.ToString()); } } } Also I should note … Read more

How can I get the baseurl of site?

I want to write a little helper method which returns the base URL of the site. This is what I came up with: public static string GetSiteUrl() { string url = string.Empty; HttpRequest request = HttpContext.Current.Request; if (request.IsSecureConnection) url = “https://”; else url = “http://”; url += request[“HTTP_HOST”] + “https://stackoverflow.com/”; return url; } Is there … Read more

Error: allowDefinition=’MachineToApplication’ beyond application level

I have downloaded the online project in ASP.Net. While running application I get an error It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. What changes should i make in web.config or elsewhere … Read more

System.Security.SecurityException when writing to Event Log

I’m working on trying to port an ASP.NET app from Server 2003 (and IIS6) to Server 2008 (IIS7). When I try and visit the page on the browser I get this: Server Error in ‘/’ Application. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this … Read more