Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6625995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:50:27+00:00 2026-05-25T21:50:27+00:00

In my ASP.NET page I have the following method: public static void UpdatePage(string accessCode,

  • 0

In my ASP.NET page I have the following method:

public static void UpdatePage(string accessCode, string newURL)
{
    HttpContext.Current.Cache[accessCode] = newURL;
}

It actually should receive the accessCode and newURL and update the Cache accordingly. I want to pass the values to that method from JavaScript, using an AJAX request. The code for it is as follows:

function sendUpdate() {
    var code = jsGetQueryString("code"); 
    var url = $("#url_field").val();
    var dataToSend = [ {accessCode: code, newURL: url} ];
    var options = { error: function(msg) { alert(msg.d); },
                        type: "POST", url: "lite_host.aspx/UpdatePage",
                        data: {"items":dataToSend}, 
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        async: false, 
                        success: function(response) { var results = response.d; } }; 
        $.ajax(options);
}

However this doesn’t seem to work. Could anybody help me figure out where the bug is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:50:28+00:00Added an answer on May 25, 2026 at 9:50 pm

    UpdatePage is a void method that doesn’t return anything, so there is nothing to look at in the response.

    You could look at the HTTP return code and check that it was 200 OK or you could modify the web method:

    public static bool UpdatePage(string accessCode, string newURL)
    {
        bool result = true;
        try {
           HttpContext.Current.Cache[accessCode] = newURL;
        }
        catch {
            result = false;
        }
    
        return result
    }
    

    Edit:

    It looks like your JSON arguments to the WebMethod are incorrect, you don’t need the “items” in your JSON. The arguments should match your webmethod exactly.

    function sendUpdate() {
           var code = jsGetQueryString("code"); 
           var url = $("#url_field").val();
           var options = { error: function(msg) { alert(msg.d); },
                           type: "POST", url: "lite_host.aspx/UpdatePage",
                           data: {'accessCode': code, 'newURL': url}, 
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           async: false, 
                           success: function(response) { var results = response.d; } }; 
           $.ajax(options);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In code-behind of an ASP.NET page I have this method: public string TestFunc() {
I have a following items displayed on an asp.net page (C#). 1 Welcome 2
I have the following code in my Site.Master page of an almost empty ASP.NET
I'm writing an ASP.NET 2.0 page in VS2008. In my Page_Load method I have
Hallo, I have following jquery code for calling ASP.NET MVC controller method that is
I have a generic method to call a stored Procedure in ASP.NET: public SqlDataReader
This is driving me crazy. I have the following string in a ASP.NET 2.0
In The Page_Load event of an ASP.NET USercontrol, I have the following Code: If
On an ASP.NET web page I have an EntityDataSource: <asp:EntityDataSource ID=EntityDataSourceOrders runat=server ConnectionString=name=EntitiesContext DefaultContainerName=EntitiesContext
I have 2 textbox in my asp.net page and also have one hiddenfield in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.