asp.net-mvc-5

Web Api FromBody is null from web client

折月煮酒 提交于 2019-12-10 02:46:53
问题 Hello I would like to call Web Api method from C# client by my body variable in web api controller is null all the time. How to set it correct ? client side: IFileService imgService = new ImageServiceBll(); var image = System.Drawing.Image.FromFile(serverFile); var dataImage = imgService.ImageToBase64(image, System.Drawing.Imaging.ImageFormat.Png); using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://site.local/"); client.DefaultRequestHeaders.Accept.Clear(); client

IdentityStoreManager could not be found after upgrading Microsoft.AspNet.Identity to rc1

蓝咒 提交于 2019-12-10 02:31:57
问题 After Upgrading Microsoft.AspNet.Identity.Core to 1.0.0-rc1 several errors appear in the AccountController.cs And AppModel.cs classes which are generated by the default MVC5 templates in Visual Studio 2013. Are there any release notes to explain how to resolve the breaking changes? 回答1: Update the following nuget packages: Microsoft ASP.NET Identity EntityFramework version="1.0.0-rc1" Microsoft.Owin.Security version="2.0.0-rc1" Microsoft.Owin.Security.OAuth version="2.0.0-rc1" Get these:

Get list data on view in controller

坚强是说给别人听的谎言 提交于 2019-12-10 02:16:18
问题 I have a view in which I have rendered partial view in a loop. There is a list and partial view have is binded with each item in a list. I am not getting the value of the list on controller after value is entered. Here is my view: <table id="resourceRequirement" class="table" width="100%" border="0"> <thead> <tr style="background-color:#dfdfdf;"> <td><div align="center">PRIORITY</div></td> <td><div align="center">SYSTEM RESOURCE / COMPONENT</div></td> <td><div align="center">RECOVERY TIME

MVC 5 AttributeRouting Catch All

依然范特西╮ 提交于 2019-12-10 02:06:25
问题 How do I create a catch all route with the new Attribute routing in MVC I tried this: [Route("{pagenode}", Order = 999)] But when I have a named route like [Route("contact"] I get the "Multiple controller types were found that match the URL. This can happen if attribute routes on multiple controllers match the requested URL." error. 回答1: You can't do this with Attribute routing, do this the MVC4 way: Map a route in your routemapper like this: routes.MapRoute("RouteName","{*url}",new {

MVC5 AntiForgeryToken - how to handle “The provided anti-forgery token was meant for user ”“, but the current user is ”xxx“.” exception?

随声附和 提交于 2019-12-10 00:55:22
问题 I want to protect our login actions by AntiforgeryToken attribute - I know why the exception from the topic occurs, however I can't seem to find any good solution for it. Let say we have the following situations: It's 8:00 AM, application users are coming to work, they sit down and starting the login process - right now it is very possible that some of the users will get the same ValidationToken . After the first one logs in - all other will see the above exception (or some other custom

Show custom error for “504 Gateway Timeout error”

大城市里の小女人 提交于 2019-12-09 23:25:25
问题 I am working to ASP.net MVC-5 project and I am a beginner. As of now I know the basics of MVC and able to display pages and make post and get request. But I am stuck with one issue where I get "504 gateway time out error" and I need to implement one functionality where if the client gets `504 gateway timeout error" I should be able to show a particular page like "Something is wrong" instead of standard error. To start with below is what I did. <system.web> <compilation debug="true"

After upgrade to EF6 - The property cannot be configured as a navigation property

牧云@^-^@ 提交于 2019-12-09 19:25:55
问题 I have a following class: [Table("TagSource")] public class TagSource { public TagSource() { this.DataSources = new HashSet<DataSource>(); } [Key] public int TagSourceId { get; set; } ... public bool IsHistorical { get; set; } public Nullable<int> ModifiedEntryId { get; set; } ... public int? AttachedTagSourceId { get; set; } [ForeignKey("AttachedTagSourceId"), InverseProperty("TagSourceId")] public virtual TagSource AttachedTagSource { get; set; } [ForeignKey("ModifiedEntryId"),

How to mock ApplicationUserManager from AccountController in MVC5

被刻印的时光 ゝ 提交于 2019-12-09 18:34:30
问题 I am trying to write Unit Test for Register Method at AccountController I am using moq and what is the correct way to mock ApplicationUserManager, ApplicationRoleManager and ApplicationSignInManager from Unit Test. public AccountController(ApplicationUserManager userManager, ApplicationRoleManager roleManager, ApplicationSignInManager signInManager) { UserManager = userManager; RoleManager = roleManager; SignInManager = signInManager; } public ApplicationUserManager UserManager { get { return

Asp.Net MVC 5 How to send ViewBag to Partial View

大城市里の小女人 提交于 2019-12-09 18:27:31
问题 I have a _LoginPartial View and want to send data to it by ViewBag, but the Controller that I'am sending data from, doesn't have a View. public PartialViewResult Index() { ViewBag.sth = // some data return PartialView("~/Views/Shared/_LoginPartial.cshtml"); } This code didn't work for me. 回答1: It seems you're expecting this Index action to be called when you do: @Html.Partial('_LoginPartial') . That will never happen. Partial just runs the partial view through Razor with the current view's

Large file upload when using ssl and client certificates (uploadReadAheadSize) but dont want all data to be readahead

一世执手 提交于 2019-12-09 17:37:03
问题 I tried to search the internet/stack overflow and couldn't find any relevant answer that worked for me. I have an asp.net web api2 application (uses ssl only). I'm trying to allow large file upload (up to ~36mb) but unless i change uploadReadAheadSize to readahead this size I get an error from IIS that the request is too long. I don't want to set that attribute because then my data stream only arrives after IIS read it all already. My question is: How can I do large file upload with asp.net