asp.net-core-mvc

Compatibility between dotnetcore and framework 4.5

主宰稳场 提交于 2019-12-02 01:07:47
I'm adding a new dotnetcore (RC2) project to my existing solution which contains a set of dotnet framewotk 4.5 projects. When I try to add a reference in my brand new dotnetcore project I get a message telling me that I can't do a reference from a project that targets framework 4.5. The following projects are not supported references: "project name" has target frameworks that are incompatible with targets in current project "project name" I followed this thread but I didn't find any clear solution for the issue. what's the recommended approach for this situation? Replace your library's project

Post using HttpClient & Read HttpResponseMessage status

二次信任 提交于 2019-12-02 01:06:48
I am posting to an API using HttpClient and getting back the HttpResponseMessage . I am reading the status code from the reply but I it's always 200 Posting: var json = JsonConvert.SerializeObject(loginDto); var stringContent = new StringContent(json, Encoding.UTF8, "application/json"); var client = new HttpClient(); var response = await client.PostAsync("http://localhost:57770/api/Account/Login", stringContent); I am replying from API the HttpResponseMessage : return new HttpResponseMessage(HttpStatusCode.Unauthorized); But when I read the response , it's always 200 How can I achieve this?

Missing CloudTable.Execute (and all non-async methods) in ASP.Net 5 Projects

主宰稳场 提交于 2019-12-02 01:05:08
Using Microsoft Visual Studio 2015 RC, if I create a new "ASP.Net Web Application", and go to NuGet and add a reference to the latest version of Azure Storage (Install-Package WindowsAzure.Storage -Pre), in the CloudTable class, all I see are the *Async methods: However, if I create a new Console Application or Class Library (normal class library and console application, not a "Package" one) then I see all the methods as I expect: And it isn't just intellisense, the methods seem to actually be missing. If I go out to the package in windows explorer I see separate folders for dnx451, dnxcore50,

ASP.NET Core: asp-* attributes use request payload over model?

孤者浪人 提交于 2019-12-02 01:03:42
问题 It seems that in ASP.NET Core, the value in asp-* attributes (e.g. asp-for ) is taken from the request payload before the model. Example: Post this value: MyProperty="User entered value." To this action: [HttpPost] public IActionResult Foo(MyModel m) { m.MyProperty = "Change it to this!"; return View(); } OR this action [HttpPost] public IActionResult Foo(MyModel m) { m.MyProperty = "Change it to this!"; return View(m); } View renders this: <input asp-for="MyProperty" /> The value in the form

Create/Get DefaultHtmlGenerator from MVC Controller

坚强是说给别人听的谎言 提交于 2019-12-02 00:59:39
I am trying to create(Or get an instance of it somehow) for Microsoft.AspNet.Mvc.Rendering.DefaultHtmlGenerator inside my MVC6 controller method I wanted to generate the html for validation for my Model my self inside my controller of asp.net mvc. My issue is where to get the constructor data for DefaultHtmlGenerator like antiforgery, metadataProvider..etc [HttpGet] public IActionResult GetMarkup() { // IHtmlGenerator ge = this.CurrentGenerator(); IHtmlGenerator ge = new DefaultHtmlGenerator(params); var tag= ge.GetClientValidationRules(params) } here is the a link about the HtmlGenerator

How do I use JavaScriptSerializer in ASP.NET 5?

前提是你 提交于 2019-12-02 00:57:02
问题 I am porting my project to DNX-Core 5.0 and trying to get work but I cannot find the JavaScriptSerializer and AppSettingReader classes. I know the System.Web is removed and so please anyone help me to find the alternative of using them. Is there any Nuget available to include them? 回答1: The ASP.Net 5 team dropped the JavaScriptSerializer in favor of the widely used Newtonsoft.Json package, but they did provide a JsonOutputFormatter and a JsonInputFormatter for use with MVC to be able to

Add Assemblies to Visual Studio 2015 ASP.NET 5

ぐ巨炮叔叔 提交于 2019-12-02 00:50:52
I want to add "Stimulsoft.Report.dll" as an assembly in my Visual Studio 2015 ASP.Net 5 project. But the reference manager does not contain the assemblies section with the extentions area(as it is in VS 2013), where i could select "Stimulsoft.Report" and add this to my references. Is there any solution adding these reference to my ASP.NET 5 project? you can add the assembly if it available in GAC like below code "frameworks": { "aspnet50": { "frameworkAssemblies": { "Stimulsoft.Report": "" } } } in the second part, you can give the version and type of the assembly Bart Calixto In your project

ASP.NET 5 Client Side Depdency Management - Bower

試著忘記壹切 提交于 2019-12-02 00:48:51
问题 I'm trying out the new ASP.NET 5 with MVC 6, and I'm using bower to manage all my client-side dependencies. Everything is working fine. But I have a question: When I add a dependency (let's say jQuery). It adds both the /dist and /src along with bower configuration files to the /lib folder of wwwroot . How do I make it include just the compiled source for usage? (So I can reference it in my pages via /lib/jquery/jquery.js ? 回答1: I have recently been playing in this space and following is

ASP.Net Core unit testing async controller [duplicate]

元气小坏坏 提交于 2019-12-02 00:35:23
This question already has an answer here: How to mock an async repository with Entity Framework Core 4 answers I have this test: [Fact] public async void Can_Paginate() { //fake data var product1 = new Product { ProductId = 1, ProductName = "P1" }; var product2 = new Product { ProductId = 2, ProductName = "Product 2" }; var product3 = new Product { ProductId = 3, ProductName = "Product 3" }; var product4 = new Product { ProductId = 4, ProductName = "Product 4" }; var product5 = new Product { ProductId = 5, ProductName = "Product 5" }; var data = new List<Product> { product1, product2, product3

How to reference .NET framework from ASP.NET Core

落爺英雄遲暮 提交于 2019-12-02 00:33:29
I have a ASP.NET MVC 5 / .NET 4.7 project that I want to upgrade to ASP.NET Core. The MVC frontend references a service layer project (SL) which in its that uses a datalayer (DAL) project built using Entity Framework. Our assessment is that Entity Framework Core is still missing features that we need and that we should not upgrade the DAL project to .NET Core. What framework should my projects target to be able to work together? Can we upgrade just one project to .NET Core and keep the rest in .NET Framework? If you want to switch to .NETCore and still be able to use older libraries you should