asp.net-core-1.1

InvalidOperationException rendering ViewComponent in Strongly-Typed View

两盒软妹~` 提交于 2019-12-07 07:07:15
问题 Recently updated dotnet core 1.0.1 to 1.1 and ViewComponent in MVC starts failing with the below exception: InvalidOperationException: One or more errors occurred. (The model item passed into the ViewDataDictionary is of type 'App.Models.HomeViewModel', but this ViewDataDictionary instance requires a model item of type 'App.Components.LoginViewComponent'.) The Index.cshtml renders LoginViewComponent : @model App.Models.HomeViewModel <html> @Component.InvokeAsync("LoginViewComponent") </html>

Aspnet Core 1.1 Missing Windows Authentication when published

帅比萌擦擦* 提交于 2019-12-07 06:06:26
I noticed that when publishing my new Aspnet Core 1.1 (just updated to VS 2017) project it is always missing the forwardWindowsAuthToken="true" from the web.config. More info and the fix I found was here: https://developercommunity.visualstudio.com/content/problem/26751/publish-aspnet-core-to-iis-with-windows-authentica.html I also tried adding: services.Configure<IISOptions>(options => { options.ForwardWindowsAuthentication = true; }); to my ConfigureServices method but it didn't help. So my question is, is there a way to get this to work properly? Some command line argument or other way to

The Language does not change in the ASP.NET Core Web application

落爺英雄遲暮 提交于 2019-12-07 02:39:27
I follow the Globalization and localization and Building simple multilingual ASP.NET Core website tutorials to add a language switch for my application. So, I created a partial view @using Microsoft.AspNetCore.Builder @using Microsoft.AspNetCore.Http.Features @using Microsoft.AspNetCore.Localization @using Microsoft.AspNetCore.Mvc.Localization @using Microsoft.Extensions.Options @inject IViewLocalizer Localizer @inject IOptions<RequestLocalizationOptions> LocOptions @{ var requestCulture = Context.Features.Get<IRequestCultureFeature>(); var cultureItems = LocOptions.Value.SupportedUICultures

Could not load assembly Microsoft.EntityFrameworkCore.Design when running Add-Migration

旧巷老猫 提交于 2019-12-05 17:25:33
I have created a Class Library project with the following .csproj: <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.sqlserver.Design" Version="1.1.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" /> </ItemGroup> </Project> When running the command: Add

InvalidOperationException rendering ViewComponent in Strongly-Typed View

半城伤御伤魂 提交于 2019-12-05 12:51:32
Recently updated dotnet core 1.0.1 to 1.1 and ViewComponent in MVC starts failing with the below exception: InvalidOperationException: One or more errors occurred. (The model item passed into the ViewDataDictionary is of type 'App.Models.HomeViewModel', but this ViewDataDictionary instance requires a model item of type 'App.Components.LoginViewComponent'.) The Index.cshtml renders LoginViewComponent : @model App.Models.HomeViewModel <html> @Component.InvokeAsync("LoginViewComponent") </html> Views/Home/Index.cshtml The ViewComponent LoginViewComponent/Default.cshtml is just a class that

Glimpse diagnostics platform which is full compatible to ASP.NET Core

淺唱寂寞╮ 提交于 2019-12-05 06:58:08
I used Glimpse on the old ASP.NET MVC5 stack and liked it very much cause it gives a pretty and detailed representation of nearly all important data for debugging purpose. Sadly, its not compatible with ASP.NET Core (yet). I tried to install the demo , which assurance to work with ASP.NET Core. But thats not entirely true cause it works on ASP.NET Core, but depends on the old 4.x framework. So it destroys the cross-platform compability, which is not suiteable for me. The app is designed to run on a Linux based server using docker. Although, I would like to benefit from those nice features in

Bad Request - Invalid Hostname when accessing localhost Web API or Web App from across LAN

与世无争的帅哥 提交于 2019-12-05 06:03:23
I have an ASP .Net Core 1.1 Web API and Web App running on my localhost from Visual Studio 2017 on Windows 10. When I run the projects, the API runs on http://localhost:50082/api/ and the web app on http://localhost:60856/ However, if others on the LAN try to access it (using my computer's IP address - http://192.168.1.101:60856/ they get a Bad Request - Invalid Hostname Error. In fact,. I get this error too of I use my IP address. I've tried about a dozen variations in my C:\Users\Documents\IISExpress\config\applicationhost.config file, such as: <bindings> <binding protocol="http"

Not able to redirect to action when using TempData in Asp.Net Core

若如初见. 提交于 2019-12-05 01:05:41
问题 I am trying to achieve a simple thing in Asp.Net Core. This would have been no big deal in Asp.Net Mvc. I have an action method like this public async Task<IActionResult> Create([Bind("Id,FirstName,LastName,Email,PhoneNo")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); TempData["CustomerDetails"] = customer; return RedirectToAction("Registered"); } return View(customer); } public IActionResult Registered() { Customer customer =

'IServiceCollection' does not contain a definition for 'AddSession'

拈花ヽ惹草 提交于 2019-12-04 04:41:30
I am getting an error while adding 'AddSession' in ASP.Net Core 1.1 using VS2017. 'IServiceCollection' does not contain a definition for 'AddSession' and no extension method 'AddSession' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) .csproj <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> </PropertyGroup> <PropertyGroup> <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback> </PropertyGroup> <ItemGroup>

Not able to redirect to action when using TempData in Asp.Net Core

此生再无相见时 提交于 2019-12-03 16:24:50
I am trying to achieve a simple thing in Asp.Net Core. This would have been no big deal in Asp.Net Mvc. I have an action method like this public async Task<IActionResult> Create([Bind("Id,FirstName,LastName,Email,PhoneNo")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); TempData["CustomerDetails"] = customer; return RedirectToAction("Registered"); } return View(customer); } public IActionResult Registered() { Customer customer = (Customer)TempData["CustomerDetails"]; return View(customer); } At first I assumed TempData works by default