asp.net-mvc

How to change site language using Resources and CultureInfo in ASP .NET MVC?

拈花ヽ惹草 提交于 2021-02-06 13:51:17
问题 I have several resource files for each language I want to support, named like below: NavigationMenu.en-US.resx NavigationMenu.ru-RU.resx NavigationMenu.uk-UA.resx Files are located in MySolution/Resources/NavigationMenu folder. I have action which sets CurrentCulture and CurrentUICulture like below public ActionResult SetLanguage(string lang) { try { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang); Thread.CurrentThread.CurrentUICulture = CultureInfo

MVC 5 IsInRole Usage on Razor Views: Cannot connect to Database

人盡茶涼 提交于 2021-02-06 10:12:37
问题 I'm having issues using the new identity system in MVC 5, my goal is to make use of the User.IsinRole("RoleName") on Views. For example: @if(User.IsInRole("Administrator")) { <li>@Html.ActionLink("Admin", "Index", "Admin")</li> } This is placed in the main layout page which is hit when the application launches. On doing this, i'm getting the following error: "An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code Additional information:

Change http status 503 to 200 when serving app_offline.htm for specific URL

纵饮孤独 提交于 2021-02-06 08:48:22
问题 The app_offline.htm file that ASP.NET serves returns the http status 503. This is the correct behavior for most situations. However, in the scenario where a specific URL is requested (e.g. https://www.mywebsite.com/monitor), I'd like to change the returned http status to 200, while still returning http status 503 in all other situations. Is this possible? The reason why I want to do this is whenever we do scheduled maintenance on our website, we use the app_offline.htm file, but we don't want

Accessing the Ninject Kernel Globally

大憨熊 提交于 2021-02-06 08:39:27
问题 This question is not specifically related to Ninject. It's more of a general coding question, but I'm posting it here in case there might be a better way entirely of handling the issue in Ninject, than what I am trying to do. I would like to know whether it is possible to access the Ninject Standard Kernel globally, from its instance in Global.asax. Here is the code: public class MvcApplication : NinjectHttpApplication { protected override void OnApplicationStarted() { base

IFormFile always null (ASP.NET Core with MVC/Razor)

送分小仙女□ 提交于 2021-02-06 07:47:26
问题 I have an ASP.NET Core MVC app attempting to upload an IFormFile. However, the IFormFile is always null. None of the other solutions I've found have solved this issue. What am I doing wrong? Model public class EmailForm { [Display(Name = "Add a picture")] [DataType(DataType.Upload)] [FileExtensions(Extensions = "jpg,png,gif,jpeg,bmp,svg")] public IFormFile SubmitterPicture { get; set; } } Controller public async Task<ActionResult> Contribute([Bind("SubmitterPicture")] EmailForm model) { if

IFormFile always null (ASP.NET Core with MVC/Razor)

杀马特。学长 韩版系。学妹 提交于 2021-02-06 07:46:32
问题 I have an ASP.NET Core MVC app attempting to upload an IFormFile. However, the IFormFile is always null. None of the other solutions I've found have solved this issue. What am I doing wrong? Model public class EmailForm { [Display(Name = "Add a picture")] [DataType(DataType.Upload)] [FileExtensions(Extensions = "jpg,png,gif,jpeg,bmp,svg")] public IFormFile SubmitterPicture { get; set; } } Controller public async Task<ActionResult> Contribute([Bind("SubmitterPicture")] EmailForm model) { if

IFormFile always null (ASP.NET Core with MVC/Razor)

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-06 07:46:25
问题 I have an ASP.NET Core MVC app attempting to upload an IFormFile. However, the IFormFile is always null. None of the other solutions I've found have solved this issue. What am I doing wrong? Model public class EmailForm { [Display(Name = "Add a picture")] [DataType(DataType.Upload)] [FileExtensions(Extensions = "jpg,png,gif,jpeg,bmp,svg")] public IFormFile SubmitterPicture { get; set; } } Controller public async Task<ActionResult> Contribute([Bind("SubmitterPicture")] EmailForm model) { if

JQuery Ajax File Upload Fail on Large Files

北城以北 提交于 2021-02-06 06:27:20
问题 I currently have a ASP.Net MVC web application that needs to upload large files using ajax. I am currently using this jQuery plugin - http://valums.com/ajax-upload/. I have also used this plugin - http://jquery.malsup.com but get the same result. The issue that I am having for large file is that the iframe that gets generated to in order for the request to be asynchronous is not loading in time. It always seems to point to this code: var doc = iframe.contentDocument ? iframe.contentDocument :

Visual Studio debugging painfully slow when loading symbols

泪湿孤枕 提交于 2021-02-05 20:44:32
问题 I have an issue which is practically similar to Visual Studio debugging/loading very slow but I haven't managed to find a solution to such a problem. I have tried all what is described within that question and still, the symbol loading for the very first time is drastically slow. Similarly to the other question, when starting an MVC project, I get several lines within the Output panel which consist of something similar to: 'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft

Visual Studio debugging painfully slow when loading symbols

走远了吗. 提交于 2021-02-05 20:43:43
问题 I have an issue which is practically similar to Visual Studio debugging/loading very slow but I haven't managed to find a solution to such a problem. I have tried all what is described within that question and still, the symbol loading for the very first time is drastically slow. Similarly to the other question, when starting an MVC project, I get several lines within the Output panel which consist of something similar to: 'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft