asp.net-core-mvc

Request BinaryRead in ASP.NET 5 (MVC6)

社会主义新天地 提交于 2019-12-01 06:35:06
I had this code working in ASP.NET MVC 5, but I can't make it works in ASP.NET MVC 6 (ASP.NET 5) Can someone help me? public EmptyResult PayPalPaymentNotification(PayPalCheckoutInfo payPalCheckoutInfo) { PayPalListenerModel model = new PayPalListenerModel(); model._PayPalCheckoutInfo = payPalCheckoutInfo; byte[] parameters = Request.BinaryRead(Request.ContentLength); if (parameters != null) { model.GetStatus(parameters); } return new EmptyResult(); } The error is in: byte[] parameters = Request.BinaryRead(Request.ContentLength); HttpRequest does not contain a definition for BinaryRead and no

.net core classlibrary calling .net framework class library

☆樱花仙子☆ 提交于 2019-12-01 06:22:06
Could not find an answer to my doubts and hopefully somebody can clarify. I Have created a dummy solution with 1 class library(.net framework) 1 .net core library Tried to reference either way but I cant,they are not compatible,fine makes sense. Now my question I have a utility class library(.net framework)with extensions,helpers etc... that is used by winforms-wpf-asp.net mvc 4,5 apps now with the event of .net core it looks to me that I cannot use this library anymore unless I port it to .net core,which then i cannot use with my other apps. What is the correct approach? Am i missing the

Get property of applicationuser from the asp.net core identity

偶尔善良 提交于 2019-12-01 05:57:41
问题 I found this link: How to get the current logged in user Id ASP.NET Core But the answers are all OUTDATED! And this SO post can not neither be a solution, its just a boilerplate workaround: How should I access my ApplicationUser properties from within my MVC 6 Views? In the mvc action: base.User is not of type ApplicationUser neither is base.User.Identity. Both can not be casted into ApplicationUser. So how can I access my custom properties put inside the applicationuser object when logged in

Update Database after Model Changes - Entity Framework 7

好久不见. 提交于 2019-12-01 05:55:47
I have created an app using the lastest ASP.NET5 MVC 6 Entity Framework 7 and setup migrations using dnx . ef migration add Initial dnx . ef migration apply This works but when I make a change to the model the database is not updated. I would like to have the database automatically update after a model change when I run the program. My research only points me to old information that doesn't seem to be appropriate to Entity Framework 7. My current code: public ApplicationDbContext(): base() { if (!_created) { Database.AsRelational().ApplyMigrations(); _created = true; } } Can someone point me

Using remote validation with ASP.NET Core

主宰稳场 提交于 2019-12-01 05:55:17
I am trying to create a remote validation as follows: [Remote("CheckValue", "Validate", ErrorMessage="Value is not valid")] public string Value { get; set; } I am using ASP.NET Core (ASP.NET 5) and it seems Remote is not available. Does anyone know how to do this with ASP.NET CORE? The RemoteAttribute is part of ASP.Net MVC Core: If you are using RC1, it is in the Microsoft.AspNet.Mvc namespace. See RemoteAttribute in github. After the renaming planned in RC2, it will be in the Microsoft.AspNetCore.Mvc namespace. See RemoteAttribute in github. For example, in RC1 create a new MVC site with

.Net CORE Dapper Connection String?

妖精的绣舞 提交于 2019-12-01 05:40:51
问题 I am setting up my first .NET Core application. I am going to user Dapper (1.50.0-rc2) for the ORM. I have added the following to my appsettings.json file. "Data": { "DefaultConnection": { "ConnectionString": "user id=exampleusername;password=examplepassword;Data Source=db.example.com;Database=exampledb;" } }, I am confused at how to get the value of ConnectionString . As .NET Core is so new, online examples are all over the place and none seem to actually cover this. 回答1: I have a sample

.net core classlibrary calling .net framework class library

折月煮酒 提交于 2019-12-01 05:32:14
问题 Could not find an answer to my doubts and hopefully somebody can clarify. I Have created a dummy solution with 1 class library(.net framework) 1 .net core library Tried to reference either way but I cant,they are not compatible,fine makes sense. Now my question I have a utility class library(.net framework)with extensions,helpers etc... that is used by winforms-wpf-asp.net mvc 4,5 apps now with the event of .net core it looks to me that I cannot use this library anymore unless I port it to

Change Global Settings Config in SignalR Core

天大地大妈咪最大 提交于 2019-12-01 05:26:56
I am using SignalR Core with ASP.Net Core . I want to override GlobalHost settings for signalR. I am getting this - protected void Application_Start(object sender, EventArgs e) { // Make long polling connections wait a maximum of 110 seconds for a // response. When that time expires, trigger a timeout command and // make the client reconnect. GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(110); // Wait a maximum of 30 seconds after a transport connection is lost // before raising the Disconnected event to terminate the SignalR connection. GlobalHost.Configuration

ASP.Net 5 MVC 6 - how to return invalid JSON message on POST using FromBody?

馋奶兔 提交于 2019-12-01 05:19:17
I am creating an ASP.Net 5 application with MVC 6, using .Net 4.5.1. I have a POST method that uses a FromBody parameter to get the object automatically. [HttpPost] public IActionResult Insert([FromBody]Agent agent) { try { var id = service.Insert(agent); return Ok(id); } catch (Exception ex) { return HttpBadRequest(ex); } } This is just a proof a concept, I won't return only the id on success or the full exception on error. When a valid JSON is sent everything works fine. However when an invalid JSON is sent, I get an exception during debug: Exception thrown: 'Newtonsoft.Json

How can I upload a file in MVC 6 under vNext?

耗尽温柔 提交于 2019-12-01 05:13:25
In MVC 5 I used to do this: var context = (HttpContextBase)Request.Properties["MS_HttpContext"]; var file = (HttpPostedFileBase)context.Request.Files[0]; Now these are not available in MVC 6 under vNext. How can I get the file(s) from the request? FileUpload isn't implemented in MVC6 yet, see this issue , and related issues such as this one for status. You can post an XMLHttpRequest from JavaScript and catch it with something like this code: public async Task<IActionResult> UploadFile() { Stream bodyStream = Context.Request.Body; using(FileStream fileStream = File.Create(string.Format(@"C:\{0}