asp.net-mvc-5

MVC 5 How to define Owin LoginPath with localized routes

ぐ巨炮叔叔 提交于 2019-12-17 21:46:25
问题 I have a MVC 5 website with localized routes defined as routes.MapRoute( name: "Default", url: "{culture}/{controller}/{action}/{id}", defaults: new { culture = CultureHelper.GetDefaultCulture(), controller = "Home", action = "Index", id = UrlParameter.Optional } ); Where the default culture results in "en-US" . The problem arises when on startup I have to define the login url using the LoginPath property, that is set once and it will always use the provided value, e.g. the default culture if

unable to apply Bootstrap classes to my EditorFor

Deadly 提交于 2019-12-17 20:53:38
问题 I am working on an asp.net mvc-5 web application , and i wrote the following :- @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) & @Html.EditorFor(model => model.Name, new { @class = "form-control" }) but this will not have any effect on the generated html, but if i changed the EditorFor to be T extboxFor i will get the effect for the form-control class ? can anyone advice on this please ? i read that this is supported only inside asp.net mvc 5.1

Weird behavior when setting a row's height on EPPlus

∥☆過路亽.° 提交于 2019-12-17 20:18:53
问题 I am building an Excel file with EEPlus under MVC-5 C# application. Everything goes as planned until I set a height on a row (so an image can fit). I load de images and set the height on column 20, like so: Image cfPhoto = null; Bitmap cfBm = null; ExcelPicture pictureCf = null; var photoInitialColumn = 0; i++; completedFormPhotos.ForEach(delegate(CompletedFormPhoto cfP) { cfPhoto = Image.FromFile(HostingEnvironment.MapPath("~/Content/Images/FormPhotos/" + cfP.Id + ".jpg")); cfBm = new Bitmap

Is it correct if i am using await + ToListAsync() over IQueryable which is not define as a task

血红的双手。 提交于 2019-12-17 20:18:31
问题 I am using asp.net MVC-5 with EF-6, and I am not sure if using await + ToListAsync is valid. For example, I have the following repository method which returns an IQueryable :- public IQueryable<TSet> getAllScanEmailTo() { return t.TSets.Where(a=>a.Name.StartsWith("ScanEmail")); } And I am calling it as follow:- var emailsTo = await repository.getAllScanEmailTo().ToListAsync(); In the beginning, I thought I will get an error because I am using "await" a method which is not defined as a task,

Mvc 5.1 MissingMethodException System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached

好久不见. 提交于 2019-12-17 19:47:05
问题 I'm update my MVC5 project to MVC5.1 and now have exception on route dictionary: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); stack trace: {"Method not found: 'System.Web.Routing.RouteValueDictionary System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object)'."} at System.Web.Mvc.RouteCollectionExtensions.CreateRouteValueDictionaryUncached(Object values) at System.Web.Mvc.RouteCollectionExtensions.IgnoreRoute(RouteCollection routes, String url, Object constraints) at System

Using ASPX View Engine with MVC 5

≡放荡痞女 提交于 2019-12-17 19:33:11
问题 Is it possible to use ASPX view engine with MVC 5? We have a product using MVC 4 on ASPX view engine and we want to migrate to MVC 5, however, when I create a new project in VS 2013, select MVC and try to add a new View, I don't see any option to add a view using ASPX View Engine. Has Microsoft stopped with ASPX View Engine? Is there any way to still use ASPX? 回答1: This is what a blog post regarding the release of VS2013 said: "The HTML editor used by Razor files (.cshtml and .vbhtml) as well

Javascript variable in razor ActionLink

ε祈祈猫儿з 提交于 2019-12-17 19:16:51
问题 var boxIdValue = 233; var result = title + '<br/>@Html.ActionLink("Detail", "Show", "Boxes", new{boxId=233}, null)'; When I hardcode boxId then it works. But when I write: var result = title + '<br/>@Html.ActionLink("Detail", "Show", "Boxes", new{boxId=boxIdValue}, null)'; It doesn't. Is it possible to mix javascript var and razor in this way? 回答1: Have a look at this related Stack Overflow question. The reason why this is a challenge is that the Razor method executes on the web server at

After update to MVC 5, iframe no longer works

拈花ヽ惹草 提交于 2019-12-17 19:14:00
问题 I updated my project MVC version to 5 and now iFrame does not load, I get this error: Load denied by X-Frame-Options: www.blahblah.com does not permit cross-origin framing. I noticed that for some reason now the X-Frame-Options header has SAMEORIGIN filled which does not allow the iframe to load a page from a different domain. This is a problem for me as I develop both the containing and inheriting page. I tried everything in IIS to change this header to no avail. Anyone encountered this yet?

How can customize Asp.net Identity 2 username already taken validation message?

久未见 提交于 2019-12-17 18:50:15
问题 How can i customize Asp.net Identity 2 username already taken validation message(Name XYZ is already taken.)? Thanks 回答1: Well, I didn't find any simple solution to this issue. And by simple i mean modifying some message in a attribute/model/controller. One possible solution could be: After executing var result = await UserManager.CreateAsync(user, model.Password); In case that result is not successful you can check it's Errors property for the "Name XYZ is already taken." pattern and replace

Updating asp.net MVC from 5.0.0-beta2 to 5.0.0-rc1

别来无恙 提交于 2019-12-17 18:44:19
问题 Last night, I decided to try and implement SignalR to my application, and because I use MVC 5, I had to use the 2.0 beta of SignalR. And oh boy, what a timing. Last night, Microsoft also decided to roll out rc1 of all their mvc 5 related packages, and updating broke a few things - mostly in the account controller that is in the template for beta2. public AccountController() { IdentityStore = new IdentityStoreManager(); AuthenticationManager = new IdentityAuthenticationManager(IdentityStore);