MVC :: IsAjaxRequest Method Doesn't Work With Some IE Requests

Sep 16, 2010

I've just discovered that the X-Requested-With header in IE is always "XMLHttpRequest, XMLHttpRequest" instead of just "XMLHttpRequest". I found the reason in MicrosoftMvcAjax.debug.js at line 280 (MVC 2.0). Seems there is no need to add this header again as it is already done in Microsoft AJAX Library. And because of this IsAjaxRequest extension method doesn't work anymore if there is no X-Requested-With param in the request body. And this make X-Requested-With header useless in IE.

In Firefox there is no problem as it doesn't append but replace the existing header value. Not tested in other browsers.

View 9 Replies


Similar Messages:

Want To Try And Test An Action Method On Controller That Itself Tests If IsAjaxRequest() Is True?

May 28, 2010

I'm just starting to use the TestHelpers in MvcContrib. I want to try and test an action method on my controller that itself tests if IsAjaxRequest() is true. I've used the same code that is shown in the TestHelper samples to set up the TestControllerBuilder

_controller = new StarsController();
_builder = new TestControllerBuilder();
_builder.InitializeController(_controller);

So that _controller has all the faked/mocked HttpContext inside it, which is really great. But what do I do now to force IsAjaxRequest() on the internally faked Request object to return true?

View 2 Replies

C# - Umbraco And YAF - Old Integration Method Doesn't Work

Aug 1, 2010

I am trying to use YAF with Umbraco. The newest version out changed enough where the old integration methods don't seem to work. I have gotten everything fairly far on my own but I have hit a brick wall with this error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Source Error:
Line 23: <img src="~/yaf/images/YAFLogo.jpg" runat="server" alt="YetAnotherForum" id="imgBanner" /><br/>
Line 24: <form id="form1" runat="server" enctype="multipart/form-data">
Line 25: <YAF:Forum runat="server" ID="yafForum" />
Line 26: </form>
Line 27: </body>

I have a feeling that YAF is not starting up the database. In previous versions of YAF there was an INIT module that you loaded in your web.config file. This module is no longer there (YAF.Base.YAFInitModule).

View 2 Replies

Web Forms :: FindControl Method Doesn't Work With Masterpage?

Feb 8, 2011

i have a masterpage and other pages. i want to use findcontrol method to find a textbox (not on the master page) to check whether it is empty or not.

my code is as folows;
Dim myContentPlaceHolder As ContentPlaceHolder = CType(Master.FindControl("MainContent"), ContentPlaceHolder)
Dim UpdatePanel1 As UpdatePanel = CType(myContentPlaceHolder.FindControl("UP1"), UpdatePanel)

View 3 Replies

C# - MembershipUser Class - Comments Method Doesn't Work?

Nov 16, 2010

I'm unable to set Comments property of a MembershipUser type objects.

E.g.

MembershipUser mu = Membership.GetUser(username);
mu.Comment = "someComments";

I'd expect this to set the Comment property of mu object to "someComments" and write changes to the database.

Later, I do a following check:
mu.Comment == "someComments";

Comment property is set to null. Is there anythign that I need to change in a web.config or...?

View 2 Replies

AJAX :: Method Doesn't Work On Panel Inside UpdatePanel

Dec 10, 2010

I have problem to show method value on asp:Panel.

This is my *.aspx code :

[Code]....

Code Behind :

[Code]....

In this case, I can't show value myMethod at code behind to aspx file where this method is called.

If I use postBackTrigger in upControl updatePanel then the method(myMehod) will show on upShow updatePanel. But the updateProgress doesn't work.

View 3 Replies

AJAX :: Calling Static Play Method Doesn't Work?

Aug 26, 2010

I have a page with an update contentpanel, with 4 panels inside. Image buttons outside the update panel control control which panel is visible. I am trying to call an animation from a javascript function, but the animation doesn't work, everything else does.

main.aspx:

[Code]....

main.aspx.vb:

[Code]....

web.config:

[Code]....

View 10 Replies

Javascript - Caching AJAX Requests - Response Doesn't Get Cached

Dec 8, 2010

I used following to cache my ASP.NET page.

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));

The problem is when I send AJAX (XmlHttpRequest) request from other page to this page, that response does not get cached on any browser but IE. (On IE, it gets cached even if I don't specify). How do I make it cache?

View 3 Replies

C# - Does MVC 2.0 Model Binding Work With Ajax Requests

Feb 23, 2010

i'm just sending a normal POST request using Ajax.BeginForm... i output the form elements using the .TextBoxFor and .HiddenFor etc... all as i should... and when it's posted via ajax to my action method, the object in the action method (named "Comment") is not populated with the values!

Am i missing something? here is the relevant part of my code to those who want to see it...

[code]....

View 2 Replies

AJAX :: Requests Work On Localhost But Not Performed On Public IP

Feb 21, 2011

I'm am experiencing some strange behavior with a website. I have a page that performs a simple AJAX request to fill a div. The data is fetched from a page in the same domain. When I perform the request using [URL]. The requests work perfectly, but when using [URL] or [URL]. My requests are simply ignored. I've used Firebug to track requests, and not even a single ajax request is performed. Normal requests (such as fetching the main page that invokes the ajax code) works fine on both scenarios.

View 2 Replies

AJAX :: Make This Work For Several Days But It Just Doesn't Work?

Oct 7, 2010

i'm trying to make this work for several days but it just doesn't work.

this is my code:

aspx page:

[Code]....

webservice:

[Code]....

this was downloaded from this website.

the problem is that the page loads fine but no autocomplete occurs.

View 5 Replies

WCF / ASMX :: Code Within A WebService And WCF Client Work Only When Fildder Is Capturing Requests?

Mar 31, 2011

I have a piece of code written in 2 different ways, one a web service and another a WCF client which are trying to access an external 3rd party URL.

The same code when written as an exe works fine, i see my submissions on the 3rd party site, while the web code does not work.

I installed Fiddler to check traffic and to my surprise the web code works when Fiddler is capturing traffic, As soon as I stop Fiddler my code does not work.

For the web service code I get error: The remote name could not be resolved:

For the WCF client I get error: There was no endpoint listening at <<3rd party URL>> that could accept the message. This is often caused by an incorrect address or SOAP action.

Am quite sure now that this is because of some network and/or proxy on my corporate network, but not able to figure out what it can be.

View 1 Replies

Ajax With WCF Work. But Few Miniute After, Doesn't Work

May 11, 2010

I am a new to WCF. I have written ajax to use a web service before, but on this project I am trying to use ajax to WCF.After I build the project and wcf using ajax, I receive the return successfully. But, 10 or more minutes later I don't get a return, the ajax calls the error function, and the fiddler returns nothing.

If I rebuild the project without any source modifying, I receive the return successfully again.

View 2 Replies

MVC :: IsAjaxRequest Is Always False?

Mar 22, 2010

i am using MVC 2 RC and VS2010

when i want to use Ajax for my application IsAjaxRequest returns false

this is my code for view

[Code]....

and this is my controller

[Code]....

also i was added these libraries to my master page

[Code]....

the Request.IsAjaxRequest returns false

View 8 Replies

MVC :: OutputCache Varyby IsAjaxRequest?

Jan 11, 2010

I've an action in a controller that returns different content if the request is Ajax or not:

[Code]....

So, from the view I can fill a <div> with the PartialView (RenderPartial), calling the same action (allowing javascript disabled clients). The problem is the cache, because when the request has cached as a normal request, if later sends the request as an Ajax request, the view is rendered very bad.

The question is: Is there any way to use OutputCache to allow to cache in different entries this two types of requests (Ajax and not Ajax).

View 4 Replies

Selectively Redirecting HTTP Requests To HTTPS Requests?

Jun 18, 2010

What's the simplest and most effective way to selectively redirect HTTP requests to your ASP.NET page to its HTTPS equivalent? For example, if my page site URL is [URL], I want to redirect some (or all) page requests to [URL] What's the easiest way to do that?

View 2 Replies

MVC :: Wrap IsAjaxRequest() And Other Extension Methods With DI For Testability?

Mar 21, 2010

I'm using IOC containers that wrap items of HttpContext, such as Request and Session variables, to simplify mocking of it for testability.

Since IsAjaxRequest() is an extension method, it doesn't show up in HttpContext.Current.Request.

Is it possible to wrap extension methods with a IOC container? How?

View 11 Replies

Ajax.ActionLink Is Not Working - Response.IsAjaxRequest() Is Always False

Feb 11, 2011

I have been googling/SO:ing this issue for a while and many seem to be sharing this, but I haven't found any successful solution to my problem.

Using MVC3 and Razor.

Master page contains:
<script src="@Url.Content("~/Scripts/jquery-1.5.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"></script>
AjaxTest.cshtml contains:
<div id="AjaxTestDiv">content</div>
@Ajax.ActionLink("Update", "AjaxTester", new AjaxOptions { UpdateTargetId = "AjaxTestDiv" })
AjaxTester action method:
public string AjaxTester()
{
if (Request.IsAjaxRequest())
{
return DateTime.Now.ToString();
}
else
{
return "FAIL";
}
}

I always get the "FAIL" returned, to a blank page, not in the targeted div.

Edit: Also note that if I remove the if (Request.IsAjaxRequest()), I still don't get back anything to the targeted div, but instead a blank page.

Edit2: Looking at the HTML generated, this is my link:

<a data-ajax="true" data-ajax-method="POST" data-ajax-mode="replace"
data-ajax-update="#AjaxTestDiv" href="/Area/AjaxTester">Update</a>

Have tried switching the method to GET, to no avail.

View 1 Replies

Doc.Save Doesn't Work With URI?

Feb 3, 2010

I am trying to save an updated xml file to a url like this:

Quote:

//save the output to a file
xmlDoc.Save("http://www.example.com/HomeNewsLinks.xml");


But I get this error: URI formats are not supported.

Did some google search on this and it seems I need to use client.uploadFile method, but I am not able to find how to declare/define filenamexxx (below) and how to pass a username/password.

Quote:

WebClient Client = new WebClient();
Client.UploadFile("http://www.example.com/HomeNewsLinks.xml", Post, filenamexxx);

View 5 Replies

Javascript - Why Doesn't This Work

Aug 10, 2010

I used this,

<a title="Logout" onclick="javascript:document.getElementById('ctl00_ContentPlaceHolder1_LbLogout').click();" href="#" class="logout">Logout</a></li>
<asp:LinkButton ID="LbLogout" runat="server" style="display:none"
onclick="LbLogout_Click">Sign out</asp:LinkButton>

View 2 Replies

TryUpdateModel Doesn't Work

Jul 14, 2010

I am following though the examples in Professional ASP.Net MVC 2 and one of the examples doesn't work for me.

[HttpPost]
public ActionResult Edit (int id, FormCollection collection)
{
Dinner dinner = dinnerRepository.GetDinner(id);
if (TryUpdateModel(dinner))
{
dinnerRepository.Save();
return RedirectToAction("Details", new { id = dinner.DinnerID });
}
return View(new DinnerFormViewModel(dinner));
}


I understand that it's suppose to take the values from the FormCollection, and then update the dinner object with it, bit I don't see the collection get referenced anywhere.

View 2 Replies

Hide Div Doesn't Work?

Aug 31, 2010

I have div which it is hidden by default , when the use clicks show link the following javascript method is called:

function ChangeControlVisibility(elementID) {
var element = $("#" + elementID);
if (element.css('display') != 'block' && element.css('display') != 'table') {
element.show();

[code]....

this step works but when i call the previous method at page_load event the method doesn't work:
element.css('display') undefined.

View 3 Replies

RegisterArrayDeclaration Doesn't Work?

Jul 27, 2010

[Code]....

And in default.aspx, the code is

[Code]....

But it is not working, the error is at alert(BiblePeopleArray(0));

View 4 Replies

SQL Server :: Method That Doesn't Use SqlConnection?

Aug 28, 2010

I always use SqlConnection() To open a connection then use the connection to interact database. But I have heard somewhere that opening SQLconnection() take a time. and if on different pages of projects I repeatedly Connect database then It will take long access time always. So I want to know that if there is any other methods which don't use the SQLConnection to interact database and increase the response time of database.

View 1 Replies

Edit Doesn;t Work In Gridview?

Apr 1, 2010

I have a Gridview in UpdatePanel and a textbox in which i input a string, the row is searched from gridview onkeyup of textbox.For example when i entered "testing" one row is displayed in gridview having "Edit" command and when i clicked on "Edit" it goes to top of the row having another data is converted into edit mode but that rows is not changed into textbox.

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved