asp.net-core-mvc

How can I set a global variable in razor page of .net core?

匆匆过客 提交于 2019-12-08 07:22:54
问题 I wanna to check if the browser is IE and do something in razor page. I just made a function in razor page to do that. However,I think use the function to check if the browser is IE in every razor page is redundant.For independent user,I just need to check this only one time and set a global variable that IsIE=true/false.And other page will easily know that if it is IE. The question is how can I get/set a global variable in razor page? Thank you. ———————————————— To @Neville Nazerane ,here is

ASP.net core MVC 6 Data Annotations separation of concerns

扶醉桌前 提交于 2019-12-08 07:04:46
问题 I want put the Data Annotations Attribute and the IClientValidatable interface in two seperate assemblies to have separation of concerns. One is called Common and the other Comman.Web. These links explain how it works in MVC 5: Keeping IClientValidatable outside the model layer http://www.eidias.com/blog/2012/5/25/mvc-custom-validator-with-client-side-validation Unfortunately in MVC 6 there is no DataAnnotationsModelValidatorProvider.RegisterAdapter( typeof(MyValidationAttribute), typeof

How to reference own css file in ASP.NET 5?

落花浮王杯 提交于 2019-12-08 07:04:38
问题 I am trying to load a file called styles.css which is located in ~/Content/css/styles.css What I tried is adding it to the _Layout page <link rel="stylesheet" href="~/Content/css/styles.css" /> This gives a 404 on that location. I like the way how bower handles external libraries and gulp magically does all the other stuff like minifying a file when I request a minified version, but through all this newness I cannot add a simple static file of my own. Could someone be so kind to help me

Add admin page without full fledged user management

左心房为你撑大大i 提交于 2019-12-08 06:45:33
问题 I am building a rather simple site with ASP.NET Core MVC 2.0 that is more or less an image gallery, just for me. I am not using any database so far. It is just a json file with metadata and the image files itself. Now this site is supposed to get a hidden admin page where I (and only I) can upload new pictures. What would be a simple but still secure way to add this admin page without having to introduce a full fledged user management to the site? I'd like to avoid to add a database and

Authentication limit extensive header size

旧时模样 提交于 2019-12-08 06:40:22
问题 I have an Asp .net mvc app that connects to an Identity server 4 identity server. When i released the app I was fased with this error. upstream sent too big header while reading response header from upstream Which i have tracked to this upstream sent too big header while reading response header from upstream I can not alter the config and sys admin has stated that we need to make the headers smaller. After looking at that i would have to agree that these headers are a bit extensive. Startup

How to find the .dnx location in mac which have .NET core alone (without mono)

北城余情 提交于 2019-12-08 06:11:48
问题 I have installed .NET Core alone (without mono) in my mac book. But i unable to find the .dnx location in my machine. I tried the following command ~/.dnx , but there no folder is available, i tried with another machine with have mono, in there, such folder is available. Really i don't know why difference in .dnx location between mono and .NET core installed machine ? I need to place a custom package in .dnx location for testing purpose instead hosting in nuget.org. How to achieve this

Changing Identity 3.0 table names in ASP.NET Core MVC6 not working

被刻印的时光 ゝ 提交于 2019-12-08 05:43:54
问题 This same question was asked and has not been answered after 12 days... I have looked at this which uses "ToTable" as an update to the question. I have looked at this which appears to be out of date. I want to change the table names of the identity 3.0 tables - ASP.NET Core. So far, using the "ToTable" option's (No. 2 above) update, I have managed to corrupt my lockfile and have as a result corrupted the project. The third option is out of date. I created a vanilla project - no changes just

Handling session timeout with Ajax in .NET Core MVC

◇◆丶佛笑我妖孽 提交于 2019-12-08 05:09:34
问题 I have a regular application using cookie based authentication. This is how it's configured: public void ConfigureServices(IServiceCollection services) { services.AddAuthentication("Login") .AddCookie("Login", c => { c.ClaimsIssuer = "Myself"; c.LoginPath = new PathString("/Home/Login"); c.AccessDeniedPath = new PathString("/Home/Denied"); }); } This works for my regular actions: [Authorize] public IActionResult Users() { return View(); } But doesn't work well for my ajax requests: [Authorize

ASP.Net Core MVC date input value

一曲冷凌霜 提交于 2019-12-08 04:55:34
问题 I created a edit view for a EF Model and have a problem with the datepicker. Whenever i try to edit a `dataset, the edit view don't show me the old date values. This is my Edit.cshtml Code: <div class="form-group"> <label asp-for="BestellungsDatum" class="control-label"></label> <input asp-for="BestellungsDatum" type="date" class="form- control" value="@Model.BestellungsDatum" /> <span asp-validation-for="BestellungsDatum" class="text-danger"></span> </div> This is what it looks like, but

Angular2 http post not passing the json object to MVC 6 controller action

痞子三分冷 提交于 2019-12-08 04:40:52
问题 I am working on an angular 2 application using asp.net MVC6. Angular2 Http post method calls the controller action and works properly when there is no parameter/properties, but when i add a parameter to the controller action, The expected JSON mapping is not happening while trying to call action with the parameter values. Debugging the action shows null value to the parameter. I tested with all the solutions provided in this discussion , but still i am getting the null value for the parameter