asp.net-core-mvc

Ajax Call in MVC Core2 Bad Request

对着背影说爱祢 提交于 2019-12-11 00:33:45
问题 I'm refracting a website over to MVC Core 2. For most of my Ajax calls I've been using the .Get() shorthand with no problem. I have one AJAX call that needs to use $ajax() and for some reason I keep getting a bad Request error. Keep in mind this code is currently working in an aspx website (other than the changed url when I refactored). function get_Data() { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "/Home/Get_Index_Values", data: JSON.stringify(), dataType:

ASPNetCore MVC Routing Let Server Handle Specific Route

我怕爱的太早我们不能终老 提交于 2019-12-11 00:16:00
问题 This is a fork of a previous, unresolved question On a remote web host, I am a user. It is a shared hosting environment. The host uses Plesk, and I am trying to fix my AspNetCore application to allow Let's Encrypt's installation and automatic renewal. I am positive the AspNetCore application is interfering with the Let's Encrypt installation and automatic renewal, since I can create an empty site and install Let's Encrypt certs with no trouble, and when I create a fresh site with a

Access _context in an ASP.NET Core MVC Model

淺唱寂寞╮ 提交于 2019-12-11 00:15:01
问题 I'm trying to interact with the database from within a Model in an ASP.NET Core 1.0 MVC project. Scaffolding has been used to create Controllers and views from the Models. Ideally I would like to access it like I would in a controller with the _context but I failed finding a way to do so. I also tried to create a new connection from the model: using (var context = new ApplicationDbContext()){ // Code here } But the ApplicationDbContext constructor requires options arguments like the default

MVC 6 - TagHelper Select

血红的双手。 提交于 2019-12-11 00:05:16
问题 This may be a stupid question but I do not know why this is the default behavior for the Select TagHelper. This is what I have in my view <select asp-for="Estimators" asp-items="Model.Estimators" class="form-control"></select> and this is the output on the page <select class="form-control" id="Estimators" multiple="multiple" name="Estimators"><option value="2">Enio LastName</option> <option value="6">Ianko Diaz</option> <option value="7">Iordan Diaz</option> <option value="8">Joan Alonso<

Request BinaryRead in ASP.NET 5 (MVC6)

我的未来我决定 提交于 2019-12-10 23:37:10
问题 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 =

Issue with reference .net core class library to project

99封情书 提交于 2019-12-10 23:33:55
问题 I created new asp.net core WebApplication and .net core class library. Then I tried to add a reference to .net core class library from asp.net core. It built ok, but it is not visible. Any idea? 回答1: Any idea? Yes, this can sometimes be related to ReSharper's cache. Follow these steps: Build > Clean Solution Resharper > Options> General > "Clear Cache" Restart Visual Studio Build > Rebuild Solution 来源: https://stackoverflow.com/questions/37419018/issue-with-reference-net-core-class-library-to

Using Linq to SQL in asp.net 5 MVC 6

萝らか妹 提交于 2019-12-10 22:46:59
问题 Can I use Linq to SQL in asp.net 5 mvc 6? There is no "Linq to SQL Classes" in "Add New Item" form I know its not supported in dot net core 5 but I don't need dnx core 5 and cross platform feature. I'm ok with dnx core 4.5.1 How can I add Linq to SQL Classes file (.dbml) to MVC 6 Project? 回答1: To add Linq To SQL Classes file, you have to add Class Library project to your solution. Now you can add Linq to SQL Classes (.dbml file) to this project. Then add reference to this Class Library from

Where should I put custom classes in ASP.NET Core project [closed]

微笑、不失礼 提交于 2019-12-10 22:22:34
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I have some utility functions and want to create classes named Utility for these functions, so that I can use these class function in more than one controllers. So where can I put these class in my folder structure in ASP.NET Core 1.1 project, and how can I access then? 回答1:

Asp Core, How to create Paging?

≯℡__Kan透↙ 提交于 2019-12-10 22:12:28
问题 I want to use PagingList<T>.CreateAsync() to create PagedList in index view but get below error in line var modelPaging = await PagingList<UserListViewModel>.CreateAsync(model, 10, page); : can not convert from system.collection.Generic.List<> to system.linq.IorderedQueryable<> my action code : [HttpGet] public async Task<IActionResult> Index(int page = 1) { List<UserListViewModel> model = new List<UserListViewModel>(); model = _userManager.Users.AsNoTracking().Select(u => new

Get Route Data in class

本秂侑毒 提交于 2019-12-10 22:09:59
问题 In MVC 5 you can get RouteData from HttpContext.Current.Request.RequestContext.RouteData In MVC 6, I want to get the RouteData, I have to access it from: IHttpContextAccessor httpContextAccessor But it doesn't have the Route Dictionary Property. How do I do this in MVC 6? 回答1: It can be extracted within any Filter, though it probably makes the most sense in a ResourceFilter. All of the various filters' *Context objects inherit from the same ActionContext which has the RouteData property you