Search Results

Search found 4 results on 1 pages for 'joshb'.

Page 1/1 | 1 

  • Can't get past "A potentially dangerous Request.Form value was detected..." error

    - by joshb
    I'm doing my first ASP.NET MVC2 project and I can't get past the "A potentially dangerous Request.Form value was detected..." error when trying to submit a form. I've done this in MVC1 using the ValidateInputAttribute and I've read about the breaking change in .NET 4 that requires setting the request validation mode in the web.config. Basically I'm doing exactly what is outlined in this thread: http://stackoverflow.com/questions/2019843/a-potentially-dangerous-request-form-value-in-mvc-2-asp-net-4-0. Nothing's working though so I must be missing something. Here's my code: Web.config <configuration> <system.web> <httpHandlers> <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/> </httpHandlers> <httpRuntime requestValidationMode="2.0" /> <pages validateRequest="true" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <controls> <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" /> </controls> </pages> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <handlers> <remove name="BlockViewHandler"/> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> </handlers> </system.webServer> </configuration> Controller action [AcceptVerbs(HttpVerbs.Post)] [ValidateInput(false)] public ActionResult Edit(Page pageToEdit) { // do stuff.... } Any ideas on what I'm doing wrong here?

    Read the article

  • JsonResult shows up a file download in browser

    - by joshb
    I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method that returns a JsonResult. Everything works great except when the response gets back to the browser it is treated as a file download instead of being passed into the success handler. Here's my code: Javascript: <script type="text/javascript"> $(document).ready(function () { $("form[action$='CreateEnvelope']").submit(function () { $.ajax({ url: $(this).attr("action"), type: "POST", data: $(this).serialize(), dataType: "json", success: function (envelopeData) { alert("test"); } }); }); return false; }); </script> Action method on controller: public JsonResult CreateEnvelope(string envelopeTitle, string envelopeDescription) { //create an envelope object and return return Json(envelope); } If I open the downloaded file the json is exactly what I'm looking for and the mime type is shown as application/json. What am I missing to make the jquery.ajax call receive the json returned?

    Read the article

  • Databinding expression for retrieving value of related collection using LINQ

    - by joshb
    I have a GridView that is bound to a LINQDataSource control that is returning a collection of customers. Within my DataGrid I need to display the home phone number of a customer, if they have one. The phone numbers of a customer are stored in a separate table with a foreign key pointing to the customer table. The following binding expression gets me the first phone number for a customer: <asp:TemplateField HeaderText="LastName" SortExpression="LastName"> <ItemTemplate> <asp:Label ID="PhoneLabel" runat="server" Text='<%# Eval("Phones[0].PhoneNumber") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> I need to figure out how to get the home phone number specifically (filter based on phone type) and handle the scenario where the customer does not have a home phone in the database. Right now it's throwing an out of range exception if the customer does not have any phone numbers. I've tried using the Where operator with a lambda expression to filter the phone type but it doesn't work: <%# Eval("Phones.Where(p => p.PhoneTypeId == 2).PhoneNumber") %> Solutions or links to any good articles on the subject would be much appreciated.

    Read the article

1