asp.net-core-mvc

Updating default front-end design of Identity Login Page in .NET core

ε祈祈猫儿з 提交于 2020-01-11 03:19:46
问题 I am developing a .NET core application with Identity login which provides a Bootstrap form In the /Identity/Account/Login page. I have imported Materialize CSS files in the wwwroot/lib folder and want to change the Login page's design with materialize css as well. The problem is /Identity/Account/Login page doesn't exist in project structure. Then how should I approach to solve this problem? 回答1: One way would be to scaffold the login page, which would add it to your project structure. Then

Advantage of using IActionResult as result type in Actions

Deadly 提交于 2020-01-10 17:30:29
问题 What's the advantage or recommendation on using IActionResult as the return type of a WebApi controller instead of the actual type you want to return? Most of the examples I've seen return IActionResult , but when I build my first site I exclusively use View Model classes as my return types.... now I feel like I did it all wrong! 回答1: The main advantage is that you can return error/status codes or redirects/resource urls. For example: public IActionResult Get(integer id) { var user = db.Users

Advantage of using IActionResult as result type in Actions

你说的曾经没有我的故事 提交于 2020-01-10 17:30:04
问题 What's the advantage or recommendation on using IActionResult as the return type of a WebApi controller instead of the actual type you want to return? Most of the examples I've seen return IActionResult , but when I build my first site I exclusively use View Model classes as my return types.... now I feel like I did it all wrong! 回答1: The main advantage is that you can return error/status codes or redirects/resource urls. For example: public IActionResult Get(integer id) { var user = db.Users

ASP.NET Core 2.0 Razor pages vs Full MVC Core

怎甘沉沦 提交于 2020-01-10 06:52:50
问题 There has been a question at SO Why is Razor Pages the recommended approach to create a Web UI in Asp.net Core 2.0? where Steve Smith has kindly explained the benefits of using Razor Pages over full MVC from the perspective of having less files. I've been using Razor Pages for a while and noticed that despite an advantage of a Razor Page simplicity, it is a bit complicated when it comes to custom routing, structuring folders and complex view model (page model seem to be cluttered). So, the

Reading a file in MVC 6

我们两清 提交于 2020-01-10 03:50:06
问题 I want to access my create.sql file in the main folder of my server. It contains queries to set up my database. I have a problem to access this file at all. 1) I cannot really get there through Configuration . I can only use AddJsonFile , AddXmlFile , and AddIniFile . And I guess this is not the best idea to put a big sql file into any of those. 2) Mvc source on github seems to be missing MapPath . So no possibility of using Server.MapPath("~/create.sql") . How to achieve this then? 回答1: As

Running MVC 6 Beta 8 application on IIS

人走茶凉 提交于 2020-01-09 11:09:05
问题 I'm trying to publish my MVC 6 Beta 8 app. I was able to successfully publish it to Azure, but when I try to publish it to ASPHostPortal, I'm getting 500 error. So I tried to publish the app to a local IIS and also failed. First, I figured out that I need to install HttpPlatformHandler (otherwise IIS was not able to load web.config). But even after that, I'm getting 502.3 error. HTTP Error 502.3 - Bad Gateway There was a connection error while trying to route the request. Also in Event Log I

How to disable browser cache in ASP.NET core rc2?

此生再无相见时 提交于 2020-01-09 07:31:11
问题 I tried this Middleware but the browser still saving files. I want user will always get the last version of js and css files. public void Configure(IApplicationBuilder app) { app.UseSession(); app.UseDefaultFiles(); app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = context => context.Context.Response.Headers.Add("Cache-Control", "no-cache") }); } 回答1: Try adding an Expires header as well: app.UseStaticFiles(new StaticFileOptions() { OnPrepareResponse = context => { context

How to disable browser cache in ASP.NET core rc2?

末鹿安然 提交于 2020-01-09 07:31:06
问题 I tried this Middleware but the browser still saving files. I want user will always get the last version of js and css files. public void Configure(IApplicationBuilder app) { app.UseSession(); app.UseDefaultFiles(); app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = context => context.Context.Response.Headers.Add("Cache-Control", "no-cache") }); } 回答1: Try adding an Expires header as well: app.UseStaticFiles(new StaticFileOptions() { OnPrepareResponse = context => { context

Get list of all routes

大憨熊 提交于 2020-01-09 06:48:49
问题 In ASP.NET Core, is there a way to see a list of all the routes defined in Startup? We are using the MapRoute extension method of IRouteBuilder to define the routes. We are migrating an older project WebAPI project. There we could use GlobalConfiguration.Configuration.Routes to get all the routes. More specifically, we are doing this within an action filter. public class MyFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext actionContext) { base

Where is Request.IsAjaxRequest() in Asp.Net Core MVC?

随声附和 提交于 2020-01-09 03:21:13
问题 To learn more about the new exciting Asp.Net-5 framework, I'm trying to build a web application using the newly released Visual Studio 2015 CTP-6. Most things looks really promising, but I can't seem to find Request.IsAjaxRequest() - a functionality I've been using quite frequently on older MVC projects. Is there a better way to do this - that made them remove this method - or is it "hidden" somewhere else? Thanks for any advice on where to find it or what to do instead! 回答1: I got a little