asp.net-mvc-2

MVC 2 AntiForgeryToken - Why symmetric encryption + IPrinciple?

∥☆過路亽.° 提交于 2019-12-09 10:06:48
问题 We recently updated our solution to MVC 2, and this has updated the way that the AntiForgeryToken works. Unfortunately this does not fit with our AJAX framework any more. The problem is that MVC 2 now uses symmetric encryption to encode some properties about the user, including the user's Name property (from IPrincipal ). We are able to securely register a new user using AJAX, after which subsequent AJAX calls will be invalid as the anti forgery token will change when the user has been

Stop exception from being thrown for non-existent controller

拈花ヽ惹草 提交于 2019-12-09 09:32:17
问题 Ok, so I am stumped on this issue. I have seen a lot of things that are supposed to resolve this issue, but I am not getting a resolution that can fulfill my requirements. I am using ELMAH to log exceptions and am getting this exception when either a URL with invalid controller or proper controller and invalid action. System.Web.HttpException: The controller for path '/BadController' was not found or does not implement IController. at System.Web.Mvc.DefaultControllerFactory

DataType vs UiHint

混江龙づ霸主 提交于 2019-12-09 08:07:18
问题 I have been using mvc2 for a while now, and when i need to set the template i use the DataType Attribute [DataType("DropDown")] public int Field { get; set; } I see others using UiHint to achieve the same results [UiHint("DropDown")] public int Field { get; set; } What is the difference between using these two attributes? Which attribute should I be normally using, or are they for different tasks? 回答1: DataType is generally used to make it known that this is a very specific version of a

Null reference exception when generating a url with UrlHelper.Action method

老子叫甜甜 提交于 2019-12-09 07:58:59
问题 For some reason, when certain bots visit the site, generating a url with the UrlHelper.Action method raises a null exception from System.Web.HttpServerVarsCollection.Get . I've done some debugging and the call stack originiates with an attempt to get the 'HTTP_X_ORIGINAL_URL' from the HttpContextBase.Request.ServerVariables collection. If I visit the same address directly from a browser - no problem. The page is server and no error is logged. It only seems to occur when visited by a bot. Not

MVC Dropdownlistfor<>

邮差的信 提交于 2019-12-09 06:49:36
问题 I just started a project in MVC. I am new to MVC asp.net. I want to add a dropdown list box like I used to add in asp.net. code glimpses in asp.net for Dropdownlist box <asp:Dropdownlist ID="ddlCity" runat="server"> <asp:ItemList Text="Kolkatta" Value="1"/> <asp:ItemList Text="New Delhi" Value="2"/> <asp:ItemList Text="Mumbai" Value="3"/> <asp:ItemList Text="chennai" Value="4"/> <asp:ItemList Text="Hydrabad" Value="5"/> </asp:Dropdownlist> I want a dropdown list box in that manner.... meaning

Calling action method in MVC with jQuery and parameters not working

℡╲_俬逩灬. 提交于 2019-12-09 06:42:56
问题 I'm trying to call an action method in an MVC application using jQuery. Basically what I want is to take the value of a couple of input fields and call the action method by clicking a button, passing the values of the input fields as parameters. But I only get the value of the "number" parameter, not the "year" parameter. function selectWeek() { $('#selectWeekButton').click(function (event) { var number = $("#selectWeekId").val(); var year = $("#selectYearId").val(); var actionUrl = '<%: Url

Asp.net MVC Label For

会有一股神秘感。 提交于 2019-12-09 05:34:45
问题 I have the following <label for="Forename">Forename</label> <%= Html.TextBoxFor(m => m.Customer.Name.Forename) %> the problem with this is that this is rendered as <label for="Forename">Forename</label> <input type="text" value="" name="Customer.Name.Forename" id="Customer_Name_Forename"> not what I want ofc. I would like an extension to render the label correctly (i.e. with the for="" attribute having the value of the input id), is there anything in MVC 2 that does this nativly before I go

ASP.Net MVC 2 on nginx/mono 2.8

删除回忆录丶 提交于 2019-12-09 04:46:42
问题 I am trying to setup ASP.Net MVC 2 application on Linux environment. I've installed Ubuntu 10.10 on VirtualBox, then installed Mono 2.8 from sources. After that I have installed nginx and configure it as recommended here. Unfortunately, FastCGI shows me standard error 500 page: No Application Found Unable to find a matching application for request: Host localhost:80 Port 80 Request Path /Default.aspx Physical Path /var/www/mvc/Default.aspx My application is located in /var/www/mvc directory.

Visual Studio 2010 Publish Web feature not including all DLLs

空扰寡人 提交于 2019-12-09 04:05:49
问题 I have an ASP.NET MVC 2 application. Web project contains a reference to SomeProject SomeProject contains references to ExternalAssembly1 and ExternalAssembly2. SomeProject explicitly calls into ExternalAssembly1, but NOT ExternalAssembly2. ExternalAssembly1 calls into ExternalAssembly2 When I perform a local build everything is cool. All DLLs are included in the bin\debug folder. The problem is that when I use the Publish Web command in Visual Studio 2010, it deploys everything except

MVC Back button issue

↘锁芯ラ 提交于 2019-12-09 02:19:53
问题 I have an action method that I need to execute when the back button is clicked. I've done this before by disabling the cache in my action method (Response.Cache.SetCacheability(HttpCacheability.NoCache). This isn't working for a different action method. For some reason when i disable the cache and hit the back button to trigger my action method the page expires. Any ideas on what the issue may be? 回答1: There is no way to know, on the server side, if the page request was the result of the back