asp.net-mvc-5

ASPX Page Response.Redirect to MVC View

╄→гoц情女王★ 提交于 2019-12-19 04:19:09
问题 Is it possible to Response.Redirect in aspx that returns a view from MVC? I have an login.aspx page that i need upon successful login to redirect to a view in ~/Views/Home/index.cshtml is this possible? I've tried to following but the url couldnt be resolved. tried: Response.Redirect("~/Views/Home/Index.cshtml"); Response.Redirect("Home"); The controller is "HomeController" and the view is "Index.cshtml" any help with how to call a controller and view or atleast just the url would help. 回答1:

Many to Many relationship in Asp.Net MVC 5 with Identity table and Custom table

此生再无相见时 提交于 2019-12-19 04:15:11
问题 I'm trying to make a relationship between the Users from the table generated by Asp.Net Identity with my own table. The relationship must be many to many, since many Users can work on the same Task (which is my table), and same time an User can work on multiple Tasks. public class Task { public int ID { get; set; } public string Name { get; set; } public string UserID { get; set; } public virtual ICollection<ApplicationUser> Users { get; set; } } public class ApplicationUser : IdentityUser {

How can I get early access to upcoming Asp.Net Identity changes?

匆匆过客 提交于 2019-12-19 04:12:28
问题 Since there are a lot of changes between each version of Asp.Net Identity, is there a way to get early access to any upcoming changes going forward? 回答1: We've started publishing nightly builds to the aspnetwebstacknightly myget feed. Currently the 1.0.0 RTM candidate version is already on the feed. Going forward as we start working on future releases, this feed will contain those previews as well. Update: Walkthrough post on how to get access 来源: https://stackoverflow.com/questions/18793746

ListBoxFor MultiSelectList does not select values

烂漫一生 提交于 2019-12-19 04:01:35
问题 I'm incredibly confused, because this seems like it should be simple but I can't get my ListBox to be populated with selected values. I've looked at several other answers and I can't figure out what I'm doing wrong. This is my model: public class ItemViewModel { public IEnumerable<Item> AllItems { get; set; } public IEnumerable<Item> SelectedItems { get; set; } } public class Item { public string Id { get; set; } public string Name { get; set; } } This is my controller action: public

Strongly-typed binding to a DropDownListFor?

﹥>﹥吖頭↗ 提交于 2019-12-19 02:46:29
问题 Normally I would bind data to a DropDownListFor with a SelectList : @Html.DropDownListFor(model => model.CustomerId, new SelectList(Model.Orders, "OrderId", "ItemName")) Is there any way to do this through strongly-typed lambdas and not with property strings. For example: @Html.DropDownListFor(model => model.CustomerId, new SelectList(Model.Orders, x => x.OrderId, x => x.ItemName)) 回答1: You could create the select list itself in the controller and assign it to a property in your view model:

Non-Azure Deployment through VS 2015 RC

ぐ巨炮叔叔 提交于 2019-12-18 23:47:19
问题 I'm trying out ASP.NET 5 and all its new features on VS 2015 Enterprise RC. To ensure smooth end-to-end deployment, I then try to deploy the application to a non-Azure private server through VS Publish feature. However, I'm missing out a very important feature: the ability to publish to a non-Azure server. In earlier versions of Visual Studio (I'm using VS 2013), the Custom options is there. I've tried tinkering with the Project Properties but nothing on how to deploy my ASP.NET 5 app to a

VirtualPathProvider in MVC 5

99封情书 提交于 2019-12-18 19:32:43
问题 I can't seem to get a custom VirtualPathProvider working in asp.net MVC 5. The FileExists method returns true but then the GetFile method isn't called. I believe this is because IIS takes over the request and does not let .NET handle it. I have tried setting RAMMFAR and creating a custom handler, as in this solution https://stackoverflow.com/a/12151501/801189 but still no luck. I get a error 404. My Custom Provider: public class DbPathProvider : VirtualPathProvider { public DbPathProvider() :

MVC 5.0 [AllowAnonymous] and the new IAuthenticationFilter

三世轮回 提交于 2019-12-18 18:53:37
问题 When I create a new asp.net mvc 4.0 application, one of the first thing I do , is create and set a custom authorize global filter like so: //FilterConfig.cs public static void RegisterGlobalFilters(GlobalFilterCollection filters) { //filters.Add(new HandleErrorAttribute()); filters.Add(new CustomAuthorizationAttribute()); } Then I create the CustomAuthorizationAttribute like so: //CustomAuthorizationAttribute.cs protected override void HandleUnauthorizedRequest(AuthorizationContext

How is Owin able to set the Asp.Net Identity authentication cookies after the Application_EndRequest stage?

六月ゝ 毕业季﹏ 提交于 2019-12-18 16:17:40
问题 As a test, I created a fresh Asp.Net MVC5 app using the latest template in Visual Studio 2013. I added the following method to Global.asax.cs: protected void Application_PreSendRequestHeaders() { Response.AppendCookie(new HttpCookie("TotalNumberOfCookiesInApplication_EndRequestIs", Response.Cookies.Count + string.Empty)); } When I start the app and do a POST to /Account/Login using the credentials of a registered user, the cookies that get returned to the client are: Note that the custom

Posting A String Array

风格不统一 提交于 2019-12-18 15:34:47
问题 How can I handle an array of input For example I have in my view: <input type="text" name="listStrings[0]" /><br /> <input type="text" name="listStrings[1]" /><br /> <input type="text" name="listStrings[2]" /><br /> In my control I try to get the values like: [HttpPost] public ActionResult testMultiple(string[] listStrings) { viewModel.listStrings = listStrings; return View(viewModel); } On debugging I can see listStrings is null every time. Why is it null and how can I get the values of the