asp.net-mvc-5

ASP.NET MVC GetFullHtmlFieldId not returing valid id

你离开我真会死。 提交于 2019-12-06 10:50:49
I have taken a look at but it did not help me out GetFullHtmlFieldId returning incorrect id attribute value ASP.NET GetFullHtmlFieldId not returning valid id Problem Basically I have the following problem: I have a custom validation attribute which requires to get the fieldId of the control public class MyValidationAttribute : ValidationAttribute, IClientValidatable { //...... Collapsed code public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { ViewContext vwContext = context as ViewContext; var fieldId = vwContext.ViewData

Using Postal and Hangfire in Subsite

扶醉桌前 提交于 2019-12-06 10:49:57
I have been trying to use Postal on my MVC5 site. When I host my webpage a subsite ie, http://localhost/Subsite I am receiving the error The virtual path '/' maps to another application, which is not allowed I have debugged it down to when the ControllerContext is being created the HttpContext isn't getting set correctly. Since I'm running Postal from Hangfire the HttpContext.Current is always null. Postal creates the ContollerContext using the code below. ControllerContext CreateControllerContext() { // A dummy HttpContextBase that is enough to allow the view to be rendered. var httpContext =

Pass selected DropDown value to the controller

我的未来我决定 提交于 2019-12-06 10:38:01
I have a DropDownList and a button on my View. On click of a button, I want to pass the selected DropDown value to the controller. How to do this? View code is as below: @model Sample2.Models.LeaveType @{ ViewBag.Title = "Status of Application"; } @{ List<SelectListItem> listItems = new List<SelectListItem>(); listItems.Add(new SelectListItem { Text = "All", Value = "A", Selected = true }); listItems.Add(new SelectListItem { Text = "Recommended", Value = "R" }); listItems.Add(new SelectListItem { Text = "Sanctioned", Value = "S" }); } <table> <tr> <td> @Html.DropDownListFor(model => model

How to design an MVC5 Global Search feature in Layout.cshtml

北慕城南 提交于 2019-12-06 10:07:26
问题 I am trying to implement a "global search" feature, that is available above our main menu, in all Views within our application. It looks like this: The "global search" is a jQuery autocomplete input field. It resides in our _Layout.cshtml, which is a shared View and gets loaded many times by other views. Essentially it will display an auto-suggestion list for search keywords. Our list of keyword suggestions is roughly 6000 items. Our HomeController looks like this: public class HomeController

Is there a way to determine an ASP.Net MVC Bundle is rendered before or not?

↘锁芯ラ 提交于 2019-12-06 08:59:56
问题 Here is the situation : On a MVC application I have a partial that is rendering a script bundle . this partial is rendered several times. Is there a built-in way to determine an specific Bundle is rendered before in some place on page ? Thanks professionals Update : here is the code for clearing the condition main layout : <html> <body> @if(someCondition){ @Html.RenderPartial("SamePartial") @Html.RenderPartial("SamePartial") @Html.RenderPartial("SamePartial") } </body> </html> and this is

Load Razor Views From Database in ASP.NET MVC 5

一笑奈何 提交于 2019-12-06 08:59:32
问题 We are trying to develop a corporate CMS application in ASP.NET MVC 5. The user needs to create a new page, change an existing page content or delete a page alltogether from an admin application. Another requirement states that some of the pages can include custom widgets which were written in Razor syntax. These 2 requirements lead me to load razor views from the database. I googled and find a couple of examples. The first one is to extend the VirtualPathProvider and register it with the

ASP.NET MVC 5 Wrong Redirect Login Page

痞子三分冷 提交于 2019-12-06 08:31:12
I'm creating ASP.NET MVC 5 with "Individual User Accounts" Authentication Template. Then I create custom login page to authenticate user from database with Forms Authentication. <authentication mode="Forms"> <forms loginUrl="~/User/SignIn" timeout="2880" protection="All" /> </authentication> For testing the custom login page, I add HomeController with Authorize attribute. After run the visual studio, it redirect to the SignIn page The problem is when I remove Authorize attribute at HomeController and add authorize filter at FilterConfig.cs public static void RegisterGlobalFilters

Concurrency in ASP .NET MVC 5 with Entity Framework

不羁的心 提交于 2019-12-06 08:23:20
I´m working on simple CMS in ASP .NET MVC 5 with Entity Framework. I have a few questions about concurrency in MVC´s applications. First of all - public section of my app (section for users without any authentification): All data (posts, category informations, tags, documents) are stored in DB (using Entity) In controllers for public section, there is only reading or writing data to DB, not deleting or editing So my first question - is it necessary to have some mechanisms to avoid concurrency dangers in public section? Will everything be correct when multiple users will be browsing my website

Token based authentication for both Web App and Web API using Azure AD B2C

萝らか妹 提交于 2019-12-06 08:15:12
Scenario: Both Web application and Web API need to be authenticated and protected from the server side. Requirement: Web application is serving the contents for the browser and browser should be calling Web API directly (i.e. Browser to API). Question: Is it possible to authenticate both Web APP and the API using tokens? Any sample code or clear direction would be highly appreciated. Normally web applications are authenticated using cookies and APIs are authenticated using tokens.There are some sample projects available here but they are either browser to API (SPA token based) or Server side

IIS 8.5 MVC5 Client Cache is ignored

霸气de小男生 提交于 2019-12-06 07:49:51
问题 TL;DR - I want the server (IIS 8.5) to return 304 not modified for the CSS and JS bundles. I've been unable to get IIS 8.5 to honor the clientCache settings in web.config. No matter what I do, I can't seem to get it to cache the static content. This is a MVC5 app in VS2013. I've got all the static files in a folder "Assets". The request looks like: http://someserver/AppName/Assets/mainjs?v=FNj_9ZPAbYVAQsyDo2F8XUnWv5NQpY4iX2RGu4NpJ5g1 Attempt #1, place a new web.config in the Assets folder