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 6679409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:21:21+00:00 2026-05-26T04:21:21+00:00

We’re upgrading a large system to ASP.NET 4, and we’ve discovered a strange issue

  • 0

We’re upgrading a large system to ASP.NET 4, and we’ve discovered a strange issue with the way paths starting with ~ are resolved for some of our Ajax requests. Our Ajax requests use Server.Execute, and the pages they execute have paths that start with ~. However, in ASP.NET 4, it seems like this path is being resolved incorrectly, treating “MyService.aspx/MyMethod” as if MyService.aspx was a folder. This is different to ASP.NET 3.5.

I’ve created a small sample to show the issue.

I’ve managed to reproduce the issue in a small sample:

~/Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<html>
<head runat="server">
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
        google.load("jquery", "1.6.4");
    </script>
</head>
<body>

<script type="text/javascript">
    $(function () {
        $.ajax({
            type: "POST",
            url: "WebService1.asmx/HelloWorld",
            success: function (msg) {
                alert(msg.text);
            }
        });
    });
</script>

</body>
</html>

WebService1.asmx.cs

public class WebService1 : System.Web.Services.WebService
{
    [WebMethod]
    public string HelloWorld()
    {
        var tw = new StringWriter();
        tw.WriteLine("VirtualPathUtility.ToAbsolute(\"~/Images/Blah.png\"): " + VirtualPathUtility.ToAbsolute("~/Images/Blah.png"));
        tw.WriteLine("VirtualPathUtility.ToAppRelative(\"~/Images/Blah.png\"): " + VirtualPathUtility.ToAppRelative("~/Images/Blah.png"));
            // Hack to use ResolveClientUrl without including a Server.Execute in the sample
        tw.WriteLine("new Image().ResolveClientUrl(\"~/Images/Blah.png\"): " + new Image().ResolveClientUrl("~/Images/Blah.png"));
        return tw.ToString();
    }
}

If you run this same code on ASP.NET 3.5 and ASP.NET 4, you’ll get different outputs:

3.5
---------------------------
VirtualPathUtility.ToAbsolute("~/Images/Blah.png"): /MyTest1/Images/Blah.png
VirtualPathUtility.ToAppRelative("~/Images/Blah.png"): ~/Images/Blah.png
new Image().ResolveClientUrl("~/Images/Blah.png"): Images/Blah.png

4.0
---------------------------
VirtualPathUtility.ToAbsolute("~/Images/Blah.png"): /MyTest1/Images/Blah.png
VirtualPathUtility.ToAppRelative("~/Images/Blah.png"): ~/Images/Blah.png
new Image().ResolveClientUrl("~/Images/Blah.png"): ../Images/Blah.png

The first two calls are the same, but the ResolveClientUrl call behaves differently. Note: We’re not actually calling ResolveClientUrl like this, it’s inside an ASPX page that is Server.Execute‘d, I just did this to keep the sample small – the issue appears to be the same.

So… Is this a bug? Is there any way I can make this work the same as in ASP.NET 4 to avoid having to move things around so that the paths work correctly?

  • 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-26T04:21:22+00:00Added an answer on May 26, 2026 at 4:21 am

    Looks like this may be a deliberate change (bug fix?) in ASP.NET 4.0, so that paths are returned correctly so that browsers would interpret them, eg.

    /MyFolder/MyPage.aspx/Something/Something
    

    In ASP.NET, the URLs would be incorrect, because they’d be based off /MyFolder/MyPage.aspx.

    I don’t think the ASP.NET 3.5 behaviour was really ever correct, it’s just what we used because that’s how it was, so it’s now become broken.

    My solution for now, is to move the asmx files up one level, so they’re a level above the pages their content is being written in to. This is a bis nasty, and only works if your pages are in a folder, but it’s easier than rewriting how this works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have some data like this: 1 2 3 4 5 9 2 6
Basically, what I'm trying to create is a page of div tags, each has

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.