asp.net-core-mvc

Serving static files in ASP.NET 5 MVC 6

别说谁变了你拦得住时间么 提交于 2019-12-23 18:44:02
问题 My wwwroot static files aren't being resolved. I understand that to serve static files, I need to put them in wwwroot: favicon.ico resolves just fine, but schema/v1-0.json does not. I get the generic message: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. I have the following wired up in Startup : app.UseMiddleware<StaticFileMiddleware>(new StaticFileOptions()); app.UseStaticFiles(); I am using DNX beta6. The above require beta5

Auto Login on debug ASP.Net Core 2.1

吃可爱长大的小学妹 提交于 2019-12-23 18:18:36
问题 I am trying to auto login for debugging purposes on an ASP.net core 2.1 application I've built. Getting the Error : HttpContext must not be null. The code below sits in the Startup.cs file // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider ServiceProvider) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home

Using [Authorize] with OpenIdConnect in MVC 6 results in immediate empty 401 response

久未见 提交于 2019-12-23 17:10:04
问题 I'm trying to add Azure AD authentication to my ASP.NET 5 MVC 6 application and have followed this example on GitHub. Everything works fine if I put the recommended code in an action method: Context.Response.Challenge( new AuthenticationProperties { RedirectUri = "/" }, OpenIdConnectAuthenticationDefaults.AuthenticationType); However, if I try using the [Authorize] attribute instead, I get an immediate empty 401 response. How can I make [Authorize] redirect properly to Azure AD? My

ASP.NET MVC6 localizable DisplayAttribute

随声附和 提交于 2019-12-23 16:42:31
问题 I wonder if there is possibility to use IHtmlLocalizer from ASP.NET MVC6 directly with POCO classes? Currently I have few viewmodels that uses DisplayAttribute in order to display translated string in views and validator, but it requires to create additional static class with each static property defined (unfortunately the static indexers are not possible in C#). Is there any better way to get this done? My current code: [Display(Name = "TrackingDevice", ResourceType = typeof(TestResource))]

Add Angular 4 to ASP.NET Core 2.0 Web Application (MVC) [closed]

我只是一个虾纸丫 提交于 2019-12-23 13:31:01
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . Now that ASP.NET Core 2 is released, I have started to build a Web Application (MVC) using ASP.NET CORE in Visual Studio 2017. However when trying to add Angular 4 (or 2) to the existing project I find many outdated tutorials on the net. I would like some guidance on how and which

ASP.NET Core TestServer results in HTTP 500 for Razor views

荒凉一梦 提交于 2019-12-23 13:02:43
问题 When I use the TestServer to call an MVC endpoint to check that the view renders, it results in a HTTP 500 Internal Server Error response. The error is: An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately. /CustomSubfolder/Views/_ViewImports.cshtml One or more compilation references are missing. Possible causes include a missing 'preserveCompilationContext'

The name <object name> does not exists in the current context

限于喜欢 提交于 2019-12-23 12:54:05
问题 Most questions are related with old version of ASP.NET MVC . My question is related to latest .NET Core build on Framework 4.6 . I created a console application and standard class library. I installed all libraries needed for running WEB on .NET Core . Everything is working fine, views are compiled fine and debugging views also working. Unfortunately, Visual Studio shows the following on any object in view: The name does not exists in the current context. How can I get rid of these red

ASP.NET 5 (RC1) Bad Gateway: The specified CGI application encountered an error and the server terminated the process

此生再无相见时 提交于 2019-12-23 12:44:46
问题 I am running an ASP.NET 5 project in an Azure Web App. When calling on an API endpoint with a file (form-data) of about 1.5mb or larger, I get a 502 Bad Gateway with the follow message in the reponse body: The specified CGI application encountered an error and the server terminated the process. The strange thing is that when uploading a smaller file, the call works fine. It seems to produce the 502 at around the 1.5mb mark, but it's not entirely consistent. I am using ASP.NET 5 RC1. In

Creating a different route to a specific action mvc 6

南楼画角 提交于 2019-12-23 12:27:58
问题 I am working on an asp.net 5 mvc api, and I am currently working on the Accounts Controller. since I saw in many different places that there is a convention of using /api/Token routing to a login in a web api. I would like to route to that specific method without the accounts prefix, I would prefer not using a different controller, and I would prefer using Attributes over routing in Startup.cs to avoid confusion in the future. this is what I have currently [Route("api/[controller]")] public

aspnet core 2.0 dotnet run running with warning

ⅰ亾dé卋堺 提交于 2019-12-23 12:17:28
问题 I upgraded to dotnet core SDK 2.0 from dotnet SDK 1.1, but on dotnet run projects that have been created with version 2.0.0 they run but with warnings. C:\Program Files\dotnet\sdk\2.0.0\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3106: Assembly strong name "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\WindowsBase.dll" is either a path which could not be found or it is a full assembly name which is badly formed. If it is a full