asp.net-mvc-5

How do I maintain a selection in my MVC 5 view's dropdownlist while paging?

懵懂的女人 提交于 2021-02-19 07:20:24
问题 I have an MVC 5 view with a search filter textbox, a search filter date dropdownlist, several sortable columns and using PgedList. Everything is working perfectly except I would like the DropDownList to maintain it's selection as the results are navigated from page to page. The filtering by the date Dropdown works just fine and is retained from page to page but I haven't figured out how to stop the dropdown list from reverting to the top selection "All" on subsequent pages (even though the

Why ASP.NET MVC app doesn't recognize user role changes right after modification?

无人久伴 提交于 2021-02-19 05:52:06
问题 I have an ASP.NET MVC hybrid app which has an ApiController besides the MVC Controllers. I'm using role based authorization attributes within both the MVC Controllers and the ApiController both at the controller level and sometimes on method level. I'm using Entity Framework 6 with Model based design. The Controller level authorizations: [Authorize(Roles = "Administrator,RegularUser")] public class EngineController : ApiController { or [System.Web.Mvc.Authorize(Roles = "Administrator

Do I need to encode attribute values in MVC Razor?

巧了我就是萌 提交于 2021-02-19 01:14:39
问题 In a cshtml file, I'm assigning a string to an attribute. For example: <input name="somename" value="@Model.Value"> Since @Model.Value string could contain any Unicode character, obviously the string must be encoded. Will Razor encode this value automatically? I'm guessing it won't or can't because I could easily put a @Html.Raw immediately after it to break up the whole thing into two tags. I think what I need to do is this: <input name="somename" value="@Html.Raw(Html.AttributeEncode(Model

Do I need to encode attribute values in MVC Razor?

天大地大妈咪最大 提交于 2021-02-19 01:12:42
问题 In a cshtml file, I'm assigning a string to an attribute. For example: <input name="somename" value="@Model.Value"> Since @Model.Value string could contain any Unicode character, obviously the string must be encoded. Will Razor encode this value automatically? I'm guessing it won't or can't because I could easily put a @Html.Raw immediately after it to break up the whole thing into two tags. I think what I need to do is this: <input name="somename" value="@Html.Raw(Html.AttributeEncode(Model

Using AspNetSqlMembershipProvider in MVC5

送分小仙女□ 提交于 2021-02-18 18:53:53
问题 working with MVC5 and trying to integrate AspNetSqlMembershipProvider than the default provider or simple membership provider. Is that possible to use AspNetSqlMembershipProvider with MVC5 ? All login and register codes looks clumsy and I am not able to figure out what exactly UserManager . I did all necessary alterations in the web.config level, still my users are not validating with the SQL Database which we have created. 回答1: AspNetSqlMembershipProvider is deprecated. ASP.NET Universal

Using AspNetSqlMembershipProvider in MVC5

守給你的承諾、 提交于 2021-02-18 18:53:41
问题 working with MVC5 and trying to integrate AspNetSqlMembershipProvider than the default provider or simple membership provider. Is that possible to use AspNetSqlMembershipProvider with MVC5 ? All login and register codes looks clumsy and I am not able to figure out what exactly UserManager . I did all necessary alterations in the web.config level, still my users are not validating with the SQL Database which we have created. 回答1: AspNetSqlMembershipProvider is deprecated. ASP.NET Universal

Redirecting to a custom route in MVC

怎甘沉沦 提交于 2021-02-11 08:06:42
问题 I have setup a custom route in my MVC site. I am having trouble figuring out how to redirect to it though. Here is my custom route code: public class MemberUrlConstraint : IRouteConstraint { public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (values[parameterName] != null) { var permalink = values[parameterName].ToString(); return string.Equals(permalink, Member.GetAuthenticatedMembersUrl(),

File Upload in ASP.NET MVC 5

限于喜欢 提交于 2021-02-11 05:57:20
问题 I am unable to upload file in folder. I am not able to find the mistake. The UploadFile View returns on same view after uploading file. Model Class: public class Upload { public int UploadId { get; set; } public string UploadTitle { get; set; } public string UploadURL { get; set; } } Here is the Controller(FileUpload) Action: public ActionResult UploadFile(HttpPostedFileBase file, Upload upload) { if (ModelState.IsValid) { if (file != null) { string fil = System.IO.Path.GetFileName(file

ASP.Net MVC: Routing issue which throwing exception

廉价感情. 提交于 2021-02-10 16:11:46
问题 I have a test controller where i have one index action which accept custid as a argument. this is how my controller looks public class TestController : Controller { // GET: Test public ActionResult Index(int custid) { return View(); } } i have added one extra routing statement in route.config file. public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "custom1", url: "{controller}/{id}",

RequireUniqueEmail = false not working MVC 5

柔情痞子 提交于 2021-02-10 10:55:18
问题 I'm developing a MVC 5 solution where I can manage "Organizations" and users can register under them. I implemented the account controller to get the Organization ID from the register form and save it inside the AspNetUsers table. Now I know which user belongs to which organization. But now I have a problem, each time I try to register an user using the same email registered to another organization I get the message: "Name t@t.com is already taken." Do you know how to make ASP.NET Membership