asp.net-mvc-5

WebAPI2 and MVC5 route config

醉酒当歌 提交于 2019-12-11 19:47:41
问题 I have coded a C# ASP.net MVC5 internet application that works well and I can do CRUD operations using a Person model. I have added a WebAPI2 controller that uses the entity framework but am getting errors when trying to browse to any of the WebAPI controller methods. The WebAPI2 controller is called PersonAPIController . The Getpeople method has the // GET api/PersonAPI comment above the method, yet when browsing to this method, I am getting this error: The resource cannot be found. Is this

ASP.NET MVC: types cast in model binding

送分小仙女□ 提交于 2019-12-11 19:29:52
问题 Is there a way to cast parameter in the controller's action from one type to another in ASP.NET MVC 5? Example. Action method is the following: public string Test(Guid input) { return ""; } If the method is invoked with parameters "input=hello" then I get the error with the message: "The parameters dictionary contains a null entry for parameter 'input' of non-nullable type 'System.Guid' for method 'System.String Test(System.Guid)' in 'RealtyGuide.WebSite.Controllers.HomeController'. An

MVC 5 show custom profile in shared layout

↘锁芯ラ 提交于 2019-12-11 18:40:55
问题 I'm just starting learning MVC 5, and i'm implementing the custom identity. So i created this class : public class ApplicationUser : IdentityUser { [Required] public string FirstName { get; set; } [Required] public string LastName { get; set; } [Required] public string Email { get; set; } public string Avatar { get; set; } } Now my question seems really simple, but i spent hours without finding a solution. What i want to do is display the custom user information in partial view. In _Layout

Check/Uncheck Parent/Child Checkboxes using Jquery in MVC

旧巷老猫 提交于 2019-12-11 18:28:48
问题 I got confused on how to achieved what I have in my mind. I hope someone might give light on what I'm going to do. I have categories, primary and sub categories. Primary categories have multiple sub categories. I think my data pulling is not a problem, displaying the data is my problem. My data is like: Foo (Primary) Foo1 (Sub) Foo2 (Sub) Faa Faa1 Faa2 Faa3 Fee Fee1 Fee2 Fee3 Fuu and so on. My expected result will be like this So far, my code is <div class="col-xs-4"> @{ foreach (var item in

ASP.NET MVC 5 POST checkboxfor to controller with onclick using Ajax

跟風遠走 提交于 2019-12-11 18:07:14
问题 I am rather new to MVC so please bear with me. My goal at hand is to POST a checkboxfor html helper that contains the property called "Verified" to my controller using Ajax. I did mounds of research and yielded this post which is very similar, however it still does not reach the controller and instead I receive a 505 error. checkboxfor Ajax link. This post didn't show how the controller handled the data being passed to the and I am lead to believe that may be my issue but I am not certain. Or

I need just to display the multiple images I insert

时光毁灭记忆、已成空白 提交于 2019-12-11 17:50:13
问题 I need just to display the multiple images I insert it save will in path, but when he showed it does show up. I don't know where is my problem but this is my code please guys help me? My Controller public async Task<ActionResult> Create(Inbox model, IEnumerable<HttpPostedFileBase> files) { var currentUser = await manager.FindByIdAsync(User.Identity.GetUserId()); if (ModelState.IsValid) { model.User = currentUser; foreach (var file in files) { if (file != null && file.ContentLength > 0) { var

How do you put an authentication token on URL as query parameter?

ぐ巨炮叔叔 提交于 2019-12-11 16:34:45
问题 I'm doing a PayPal Express Checkout on my ASP.Net MVC site. The site uses token authentication so I'm trying to put the token on the PayPal return URL as a query parameter. I have a handler that intercepts all requests to my site and extracts the token from the URL or the request header. Works fine getting it from the header but I get the following exception when its a query parameter. I get the token from my claims principal and don't do any encoding/decoding. I've tried this method but had

Having trouble sending formatted TextBoxFor Value back to the controller

孤者浪人 提交于 2019-12-11 16:19:50
问题 The following code works fine when I enter a number (e.g., 123456) without commas: the number is sent to the Save action of the controller and 123,456 is displayed in the textbox. However, when when I click Save again, and try to enter the number 123,456 with the comma, the Save action only receives a zero in the model parameter and a zero is then displayed in the textbox. What am I doing wrong? Here is the model class: public class FormatTextBoxFor { public double MyDouble { get; set; } }

Using BeginCollectionItem for adding/deleting Lineitems in MVC5 partialview

落花浮王杯 提交于 2019-12-11 16:06:39
问题 I'm trying to add/delete EnquiryLineItems into Quotation View. Tried to follow MVC 5 Dynamic Rows with BeginCollectionItem BeginCollectionItem partial within partial not behaving correctly MVC 5 BeginCollectionItem with Partial CRUD But while clicking on Add it throws error Failed to load resource: the server responded with a status of 500 (Internal Server Error) and probably constructing wrong URl ( http://localhost:53363/Enquiries/CreateLineItem?_=1505728151541 - as per the error message )

ClaimsPrincipal.Current Visual Studio 2017 different behavior

我怕爱的太早我们不能终老 提交于 2019-12-11 16:00:42
问题 I am running a VS2012 MVC 5 project on 2017 . All seems to work fine except that ClaimsPrincipal.Current does not return the same thing!! The exact same code works perfectly on VS2012 , Development and Production server. Although when running the project from VS2017 ClaimsPrincipal.Current behaves differently. Doing some research i found this article http://davidpine.net/blog/principal-architecture-changes/ Stating that in .NET Core ClaimsPrincipal.Current should behave differently . Thing is