asp.net-mvc-5

How to integrate WebApi 2 with Spring.Net

戏子无情 提交于 2019-12-07 19:39:17
问题 Im trying to integrate WebApi 2 with Spring.Net with not success. This is what i have tried: public class MvcApplication : SpringMvcApplication { protected void Application_Start() { XmlConfigurator.Configure(); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); } } When is creating the

Based on class that has no key defined mvc5

坚强是说给别人听的谎言 提交于 2019-12-07 17:52:08
问题 I try to add view from this controller . I only need this view to show data not for insert or update or delete public ActionResult Index() { var CartObj = ShoppingCart.GetCart(this.HttpContext); var classshop = new New { CartItems = CartObj.GetCartItems(), CartTotal = CartObj.GetSum() }; return View(classshop); } namespace MusicStore.Models { public class ShoppingCart { MusicStoreEntities dbo = new MusicStoreEntities(); string ShoppingCartID { get; set; } public const string CartSessionKey =

MVCSiteMapProvider breadcrumbs incorrect parent node id

半腔热情 提交于 2019-12-07 13:30:49
问题 I have this sitemap: <mvcSiteMapNode title="Projects" controller="Projects" action="Index" key="Home" visibility="!*"> <mvcSiteMapNode title="Projects" controller="Projects" action="Index"> <mvcSiteMapNode title="Project" controller="Projects" action="Details" preservedRouteParameters="id"> <mvcSiteMapNode title="Session" controller="Sessions" action="Details" preservedRouteParameters="id"> <mvcSiteMapNode title="Edit Session" controller="Sessions" action="Edit" preservedRouteParameters="id"/

Override view in ASP.NET MVC site not working

江枫思渺然 提交于 2019-12-07 12:59:55
问题 I have a separate project in my solution that contains some Controllers and compiled views. I use those controllers for base classes to other controllers in my MVC application and the views are compiled using RazorGenerator. Lets say B is Base Controller with non abstract action method SomeAction that returns View("_MyView"). _MyView.cshtml is compiled using RazorGenerator. Lets say controller A inherits B but doesn't override SomeAction . I've tried to make another view "~/Views/A/_MyView

Places you can add password validation in MVC?

蹲街弑〆低调 提交于 2019-12-07 12:47:48
问题 I've got a "ForceChangePassword" page for after "ForgotPassword" and it is randomly throwing two length requirements on the "NewPassword" field. The problem is, I never added a length requirement of 7 and have no idea where it is coming from or how to change it. Errors from ModelState The New password must be at least 6 characters long. The 'New password' field is an invalid password. Password must have 7 or more characters. if (!ModelState.IsValid) { return View(model); } // Only line

ASP.NET MVC 5 - create own login

混江龙づ霸主 提交于 2019-12-07 12:30:38
问题 Hy, I'm very new to MVC 5 (or any other MVC). I want to create my own custom login with registration. Can somebody point me to this? The login should have a simple email and password textbox. The registration should have additional data like first/lastname, age, etc. which stored in a table (user) and a dropdownbox with roles to select (stored in table "roles"). After successful login/registration should the user be redirected to the dashboard. Or is there a good tutorial about this for MVC 5

Public Conditional Razor Views with minified JS and CSS

折月煮酒 提交于 2019-12-07 11:32:10
问题 I am using ASP.NET MVC 5 to develop my website. I'm using Grunt to minify my CSS and JS. Everything works fine, but I need to change the route source of my files if I'm making a publish (release mode) or I'm debugging (I need to read my CSS and JS clearly). Something like this: [Debug Mode] <script src="scripts/myscript.js"></script> [Relase Mode or Public Mode] <script src="dist/myscript.min.js"></script> I have read this post on StackOverflow(Razor view engine, how to enter preprocessor(#if

Foolproof RequiredIfTrue not working for MVC5?

☆樱花仙子☆ 提交于 2019-12-07 09:55:31
I am trying conditional required field. If user selects ContactByPhone checkbox I am showing ContactPhoneNumber field and it should be required filed. If user doesn't select ContactByPhone then ContactPhoneNumber is invisible and not required. Validation is not showing on client side. and after I submit the form ModelState.IsValid is false for this property. How to handle this? I think I referenced all scripts on the page. Do we have any alternative solution for this situation? Model public class Contact { [Display(Name = "by Phone")] public bool ContactByPhone { get; set; } [RequiredIfTrue(

Why Scripts.Render invoke JsMinify.Process?

风流意气都作罢 提交于 2019-12-07 08:59:06
问题 I profiled my ASP.NET MVC application and I saw strange a function calls. You can see it on image Always when mvc render layout we invoke system.web.optimization.scripts.render which invoke JsMinify.Process and Minifier.MinifyJavaScript , but I thought what minification should be one time on the start app. Am I right? Maybe must I set some settings for optimization it? Conditions: localhost release BundleTable.EnableOptimizations = true; 回答1: Great Question! Intuitively, you are right,

Dead simple ASP.NET MVC 5 password protection?

穿精又带淫゛_ 提交于 2019-12-07 08:55:09
问题 I have an ASP.NET MVC 5 web application running on Azure as a webrole. Is there any way to easily password protect the entire website? I do not want any signup or account handling, just a single password to enter the site (and perhaps a username, but that's not required). Something similar to a .htaccess file. Every example on authentication for ASP.NET MVC I'm looking at comes with an enormous amount of code to implement, and Azure does not seem to be able to support Basic Authentication (at