asp.net-mvc-5

How to remove schema node in web api if return format is xml?

你离开我真会死。 提交于 2019-12-21 04:55:23
问题 I have a web api method that takes format as a parameter that provides returning both xml and json.The data type that method return is DataTable.In json format everything looks fine but in xml format the schema of datatable and some other attributes in xml nodes also returning.How to return simple xml that includes only data of datatable?Also, I am using QueryStringMapping in WebApiConfig. This is WebApiConfig Code public static void Register(HttpConfiguration config) { config

No valid key mapping found for securityToken

别说谁变了你拦得住时间么 提交于 2019-12-21 04:29:12
问题 I am developing test application for displaying claims of authenticated identity in MVC-ASP.net (Visual studio 2013) I have given authentication from active directory in following way. 1.Add new mvc project in solution . 2.click on Change authentication. 3.select organization account 4.select on premises. 5.given federation url 6.App Id url After running the application i am getting following error. WIF10201: No valid key mapping found for securityToken: 'System.IdentityModel.Tokens

How to hold the cookies claims updated with MCV5/OWIN

一个人想着一个人 提交于 2019-12-21 04:25:15
问题 We’re working on an OWIN MVC5 project. We use an own implementation of IUserStore<T> to integrate the user-management which is part of our companies framework. So far this works fine. We want to provide role membership and other security configuration through claims. I have seen (and quickly tested) the ways of either implementing IUserClaimStore<T> or of attaching a ClaimsIdentityFactory to the UserManager. In both scenarios, I see the issue that the claims are stored in the user’s cookie

ASP .Net MVC 5 JsonResult caching

北战南征 提交于 2019-12-21 04:17:14
问题 can someone explain me how to implement caching of JsonResult actions in MVC 5 application? I want to use caching of some ajax -called actions using [OutputCache()] attribute. Some of these actions return ActionResult with html -content, some JsonResult with serialized lists of {Id, Title} pairs which I'm going to use to construct dropdown lists. My goal is to reduce amount of DB-queries (while building ViewModels) and server requests (when using ajax-calls for it). So, my code looks like

Communication between a WebJob and SignalR Hub

。_饼干妹妹 提交于 2019-12-21 04:06:15
问题 I have the following scenario: I have an azure webjob (used to send mails) and I need to check the progress of the webjob in my web application. I am using SignalR to communicate with clients from my server. When I want to send an email, I push a message in the queue and the azure webjob does his job. The question is, how can I communicate the progress of the webjob to the client? Originally my idea was to push a message from the webjob, so the Hub could read it from the queue. Then, I would

FormsAuthentication object obsolete [using MVC5]

牧云@^-^@ 提交于 2019-12-21 03:43:20
问题 I'm using the following code in an MVC5 site: [HttpPost] [ValidateAntiForgeryToken] public ActionResult Login(LoginModel loginModel) { if (ModelState.IsValid) { var authenticated = FormsAuthentication.Authenticate(loginModel.UserName, loginModel.Password); if (authenticated) { FormsAuthentication.SetAuthCookie(loginModel.UserName, true); return RedirectToAction("AdminPanel"); } ModelState.AddModelError("", "The username and password combination were incorrect"); } return View(loginModel); }

ASP.NET Identity 2 UserManager get all users async

放肆的年华 提交于 2019-12-21 03:21:29
问题 Can somebody tell if there is a way to get all users async in ASP.NET Identity 2? In the UserManager.Users there is nothing async or find all async or somwething like that 回答1: There is no way to do this asynchronously with the UserManager class directly. You can either wrap it in your own asynchronous method: (this might be a bit evil) public async Task<IQueryable<User>> GetUsersAsync { return await Task.Run(() => { return userManager.Users(); } } Or use the ToListAsync extension method:

Could not load file or assembly 'System.Web.Mvc' . How to use the correct reference?

橙三吉。 提交于 2019-12-21 03:20:16
问题 I have an application built on ASP.NET web forms which also supports MVC 5. I included MVC 5 API controllers in my project for which I had to upgrade Json from version 4.5 to 7.0. After making those changes when I launched the application, I get the following error: Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) I checked the reference for System

MVC5 view drop down list

空扰寡人 提交于 2019-12-21 03:18:09
问题 In a C# MVC5 Internet application view, how can I display a dropdown list for a user to select a list item that is populated from a View Model list? Here is the ViewModel code: public class MapLocationItemViewModel { [Editable(false)] public int mapLocationForeignKeyId { get; set; } public List<string> mapLocationItemTypes { get; set; } public MapLocationItem mapLocationItem { get; set; } } Here is the code that I currently have in the View : <div class="form-group"> @Html.LabelFor(model =>

How to add claims in a mock ClaimsPrincipal

谁都会走 提交于 2019-12-21 03:11:05
问题 I am trying to unit test my controller code which gets the information from the ClaimsPrincipal.Current. In the controller code I public class HomeController { public ActionResult GetName() { return Content(ClaimsPrincipal.Current.FindFirst("name").Value); } } And I am trying to mock my ClaimsPrincipal with claims but I still don't have any mock value from the claim. // Arrange IList<Claim> claimCollection = new List<Claim> { new Claim("name", "John Doe") }; var identityMock = new Mock