The required anti-forgery form field “__RequestVerificationToken” is not present Error in user Registration
You have [ValidateAntiForgeryToken] attribute before your action. You also should add @Html.AntiForgeryToken() in your form.
You have [ValidateAntiForgeryToken] attribute before your action. You also should add @Html.AntiForgeryToken() in your form.
You have to override the HandleUnauthorizedRequest as specified here. public class CustomAuthorize: AuthorizeAttribute { protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { if(!filterContext.HttpContext.User.Identity.IsAuthenticated) { base.HandleUnauthorizedRequest(filterContext); } else { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new{ controller = “Error”, action = “AccessDenied” })); } } } **Note: updated conditional statement Jan ’16
Maybe you have to execute the following in the Visual Studio Tools command prompt: aspnet_regiis -i You can read more about the ASP.NET IIS Registration Tool (Aspnet_regiis.exe) here.
The ApiController has a property called Url which is of type System.Web.Http.Routing.UrlHelper which allows you to construct urls for api controllers. Example: public class ValuesController : ApiController { // GET /api/values public IEnumerable<string> Get() { // returns /api/values/123 string url = Url.Route(“DefaultApi”, new { controller = “values”, id = “123” }); return new string[] { … Read more
See the summaries below each quote for a quick answer, and the paragraphs for detail. Also see the References section at the end for the authoritative sources. Summaries 1.What is SimpleMembership/SimpleMembershipProvider (WebMatrix.WebData) and what is it/are they responsible for? SimpleMembership (a term that covers both the SimpleMembershipProvider and SimpleRoleProvider) is responsible for providing a clean … Read more
Basically, Should everything be done through the viewmodel or is it Ok to also incorporate viewbag? Everything should be done inside a view model. That’s what a view model is. A class that you specifically define to meet the requirements of your view. Don’t mix ViewBags with ViewModels. It is no longer clear for the … Read more
You can put them in separate namespaces, e.g MyApp.Controllers.UsersController and MyApp.Controllers.WebAPI.UsersController. This would let you expose similar URI routes in MVC and WebAPI, eg: /users/1 << MVC view /api/users/1 << Web API
If you try to parse a form that is already parsed it won’t update What you could do when you add dynamic element to the form is either You could remove the form’s validation and re validate it like this: var form = $(formSelector) .removeData(“validator”) /* added by the raw jquery.validate plugin */ .removeData(“unobtrusiveValidation”); /* … Read more
Found an answer here by Mehdi Golchin which seems to take care of: [Authorize(Roles=”admin,editor,publisher”)] If I also add this to the home controller: [InitializeSimpleMembership] Because this attribute is on the Accounts controller, SimpleMembership database gets initialize only after the first use of the accounts controller like login/register. Even when the current user gets logged in … Read more
The following code, in my Global.asax, works for me: public static void RegisterWebApiFilters(System.Web.Http.Filters.HttpFilterCollection filters) { filters.Add(new MyWebApiFilter()); } protected void Application_Start() { RegisterWebApiFilters(GlobalConfiguration.Configuration.Filters); }