asp.net-core-mvc

How to pass the model from the razor page to its master/layout page?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 02:23:28
问题 I have a page with following on top: @model AppMainModel @{ ViewData["Title"] = "Home Page"; } I would like to use AppMainModel and its properties in its master/layout page. Strongly typed if possible (e.g. avoid ViewData and the like). Is this possible? 回答1: The ViewModel data is available to the layout page. You can consider having a page viewmodel class with the common data if you want it to be strongly typed in the layout page. If not, simply pass in the common thing using the dynamic

empty model submitted from the form

▼魔方 西西 提交于 2019-12-12 02:18:25
问题 I'm using the latest preview of Asp.Net Core. I have a page with pretty simple edit form and some additional data displayed. @model SeasonFullDetailsViewModel ..... <form asp-action="Save"> <div class="form-horizontal"> <hr /> <div asp-validation-summary="ModelOnly" class="text-danger"></div> <input type="hidden" asp-for="SeasonId" /> <div class="form-group"> <label asp-for="Season" class="col-md-2 control-label"></label> <div class="col-md-10"> <input asp-for="Season" class="form-control" />

Setup MongoDB in VNext

孤人 提交于 2019-12-12 01:49:46
问题 I have some issues using MongoDB in the a VNext project Link to github with code https://github.com/Mech0z/MagicDraftStatistics/tree/NewFeatures If I use this package mongocsharpdriver Which is now obsolete, I get Warning 'MongoClientExtensions.GetServer(MongoClient)' is obsolete: 'Use the new API instead.' and 6 of these Error The type or namespace name 'MongoServer' could not be found (are you missing a using directive or an assembly reference?) And I am not sure if I need to change

ASP.NET Core Compression Middleware - Empty Reponse

此生再无相见时 提交于 2019-12-12 01:47:31
问题 I am using some custom compression middleware from this repository (pasted below). Upon the first request, the content is compressed just fine. For every request after that, the response comes back as completely empty (with a Content-Length of 0). This only started happening after migrating from ASP.NET Core RC2 to RTM. Does anyone know why this is happening? CompressionMiddleware: public class CompressionMiddleware { private readonly RequestDelegate _next; public CompressionMiddleware

JwtBearerAuthentication Safe Handle Exception

浪子不回头ぞ 提交于 2019-12-12 01:42:27
问题 When using the JwtBearerAuthentication middleware, The RSACryptoServiceProvider and other objects are disposed in the SigningCredentials after JwtSecurityTokenHandler.WriteToken() is called. My issue is very similiar to this issue: https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/477. The first request works, but any subsequent requests fail. This functionality worked great in RC2... but now that we've upgrade to 1.0, WriteToken results in: System

Can I create an ASP.NET Core MVC Website using .NET 4.6?

末鹿安然 提交于 2019-12-12 01:39:38
问题 I'm a little confused when it comes to creating ASP.NET Core MVC applications. I know I can create an ASP.NET Core MVC application if I used the newly released .NET Core 1.0 framework. I was wondering if I could create one using .NET 4.6 though. I created a new MVC application using .NET 4.6 but none of the new features, such as tag helpers, are available. Do I need to reference certain libraries? Is this even possible to do? I should state that what I'm really after is being able to use the

Resize images with MVC 6 on Ubuntu running ASP.NET 5 on Mono

心已入冬 提交于 2019-12-12 01:36:05
问题 How can I re-size an image in ASP.NET 5, MVC 6, DNX451, with MONO, running on Ubuntu? I have been unable to work this out, as the standard components that I have used such as ImageProcessor and ImageResizer.NET seem not to be working. 回答1: check out this cross platform library: https://github.com/JimBobSquarePants/ImageSharp sample usage: using (FileStream stream = File.OpenRead("foo.jpg")) using (FileStream output = File.OpenWrite("bar.jpg")) { Image image = new Image(stream); image.Resize

web.config in asp.net MVC core Project

喜夏-厌秋 提交于 2019-12-12 00:52:31
问题 I am really new to Asp.net MVC core , my visual studio is on macOS , so I had to publish my project on Azure. I wanted to transfer this project on Godaddy host. I download the files and uploaded on the Godaddy host. the problem is that it has Error 500. Is there any thing which I can do to fix it? here is my webconfig , <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType=

Getting sqlite to work in ASP.NET 5 (vnext)

淺唱寂寞╮ 提交于 2019-12-11 20:40:18
问题 I'm trying to get "EntityFramework. SQLite ": "7.0.0-beta1" to work within ASP.NET 5. I've created my project using Yeoman and installed EF sqlite from the package manager. The project builds fine but when running I get: Could not load file or assembly 'Microsoft.Framework.Logging.ILogger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'or one of its dependencies. My project.json: "dependencies": { "Microsoft.AspNet.Diagnostics": "1.0.0-beta5", "Microsoft.AspNet.Mvc": "6.0.0-beta5",

“No records to display” in Telerik's TreeList

亡梦爱人 提交于 2019-12-11 19:15:46
问题 I have simple TreeList, which I want to be filled up with some values. My TreeList: @(Html.Kendo().TreeList<Book>() .Name("BooksTreeList") .Columns(columns => { columns.Add().Field(c => c.BookName); columns.Add().Field(c => c.BookAuthor); }) .Filterable() .Sortable() .DataSource(dataSource => dataSource .Read(read => read.Action("ReadAllBooks", "Catalog")) .ServerOperation(false) .Model(m => { m.Id(c => c.BookId); m.ParentId(c => c.ParentId); m.Expanded(true); m.Field(x => x.BookId); m.Field