asp.net-mvc-5

Display mvc partial view with errors on parent page

大兔子大兔子 提交于 2019-12-05 01:40:46
问题 I have a page with multiple forms, each as a partial. I want to post each partial on submit. If there are errors, I want the validation errors to show in the partial as part of the main page i.e. I don't want to just see the partial on it's own page if there are errors. Am I correct in saying this behavior is only possible with an ajax post? How would I return the model state errors WITHOUT an ajax post, just a normal form post? Edit: Still seeing the partial on it's own page Partial - @using

MVC 5 AttributeRouting Catch All

a 夏天 提交于 2019-12-05 01:26:57
How do I create a catch all route with the new Attribute routing in MVC I tried this: [Route("{pagenode}", Order = 999)] But when I have a named route like [Route("contact"] I get the "Multiple controller types were found that match the URL. This can happen if attribute routes on multiple controllers match the requested URL." error. You can't do this with Attribute routing, do this the MVC4 way: Map a route in your routemapper like this: routes.MapRoute("RouteName","{*url}",new { controller = "YourFancyController", action = "YourAction" }); This will be your catch-all Route. If you would like

IdentityStoreManager could not be found after upgrading Microsoft.AspNet.Identity to rc1

邮差的信 提交于 2019-12-05 00:41:10
After Upgrading Microsoft.AspNet.Identity.Core to 1.0.0-rc1 several errors appear in the AccountController.cs And AppModel.cs classes which are generated by the default MVC5 templates in Visual Studio 2013. Are there any release notes to explain how to resolve the breaking changes? Update the following nuget packages: Microsoft ASP.NET Identity EntityFramework version="1.0.0-rc1" Microsoft.Owin.Security version="2.0.0-rc1" Microsoft.Owin.Security.OAuth version="2.0.0-rc1" Get these: Microsoft.AspNet.Identity.Owin version="1.0.0-rc1" Microsoft.Owin.Host.SystemWeb version="2.0.0-rc1" Then you

Kendo UI reference not working in Razor view

半腔热情 提交于 2019-12-04 23:55:16
I am trying to create a Telerik Grid view but when I go to reference kendo it does not recognize it. Visual Studio is giving me an error when I try to reference kendo. This is the code @(Html.Kendo().Grid) and below is the error. 'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'Kendo' and no extension method 'Kendo' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<dynamic>' could be found (are you missing a using directive or an assembly reference?) I have added a bundle in the BundleConfig file for both Scripts and Content. Also I have added @Scripts.Render

MVC5 AntiForgeryToken - how to handle “The provided anti-forgery token was meant for user ”“, but the current user is ”xxx“.” exception?

半腔热情 提交于 2019-12-04 23:10:19
I want to protect our login actions by AntiforgeryToken attribute - I know why the exception from the topic occurs, however I can't seem to find any good solution for it. Let say we have the following situations: It's 8:00 AM, application users are coming to work, they sit down and starting the login process - right now it is very possible that some of the users will get the same ValidationToken . After the first one logs in - all other will see the above exception (or some other custom exception screen) when they attempt to login. Some user logged in, then accidentally pressed the " back "

How to inspect MVC response stream using OWIN middleware component?

こ雲淡風輕ζ 提交于 2019-12-04 23:08:30
问题 This question has been asked before in a few forms but I cannot get any of the answers to work, I'm losing my hair and unsure if the problem is just that the solutions were from 2 years ago and things have changed. How can I safely intercept the Response stream in a custom Owin Middleware - I based my code on this, it looks like it should work, but it doesn't OWIN OnSendingHeaders Callback - Reading Response Body - seems to be a different OWIN version, because method signature doesn't work

MVC5 and Bootstrap3: Html.EditorFor wrong class? How to change?

无人久伴 提交于 2019-12-04 22:43:45
I just noticed that MVC 5 is using a different class for input fields when using EditorFor. I think its from a lower version of bootstrap, so the current class doesn't really add up. I'm talking about this: <div class="form-group"> @Html.LabelFor(model => model.Contact.CellphoneNo, new { @class = "control-label col-md-4"}) <div class="col-md-8"> @Html.EditorFor(model => model.Contact.CellphoneNo) @Html.ValidationMessageFor(model => model.Contact.CellphoneNo) </div> </div> Which results to this: <div class="form-group"> <label class="control-label col-md-4" for="Contact_CellphoneNo">CellphoneNo

Extending ASP.NET MVC 5 Identity with another object

北城以北 提交于 2019-12-04 22:37:48
I'm currently using Fluent API in which I cannot find many resources regarding extending the Identity model with another object. Here I have my object called ApplicationUser: public class ApplicationUser : IdentityUser { public virtual Staff Staff { get; set; } public int StaffId { get; set; } } In which I'd like to map it to my current Staff object: public class Staff { public int StaffId { get; set; } public string DisplayName { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public UserTitleEnum Title { get; set; } public string Phone { get; set; }

ASP.NET MVC5: Want to update several items in Collection with model binding

女生的网名这么多〃 提交于 2019-12-04 22:05:34
问题 So I have a Collection of User objects, which should be mass-editable (edit many users at the same time). I'm saving the user input to the database using Entity Framework. The collection the controller method gets from the form is null. Why? Also, is the BindAttribute possible to use with collections like in my code? View: @model IEnumerable<Domain.User> @using (Html.BeginForm("UpdateUsers", "Users")) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) foreach (var item in Model) { @Html

Extending asp.net identity in asp.net mvc 5 application

人走茶凉 提交于 2019-12-04 21:45:09
I am working on asp.net MVC 5 application. I am using Identity for creating users. I am using it first time and creating first mvc 5 application. I have two types of users. I want two tables for both types of users. So first record should be inserted in aspnetuser table and then in related tables and aspnetuser table should be linked with both tables so that i can access them. I have created models for both types of users. How can i link them with identity in model ? Please suggest Well, first, you can only truly have one user, at least in terms of the stuff Identity does. You can subclass