Question

I'm having a problem with one of my VS 2010 problems. Lets say I have a page, MyPage.aspx, in web site, MyWebSite ,with virtual path of ,MyWebSitePath. When I redirect call to another page, MyPage1.aspx, my virtual path doubles and I get HTTP Error 400 - Bad Request, which makes sense because the Url I'm getting is MyWebSite/MyWebSite/MyPage1.aspx.

I use Response.Redirect("~/MyPage1.aspx",true);

I had already tried playing with the string of redirected page. It's not that, I'm guessing it's probably in the SLN file somewhere, but I really have no idea.

An example of code that goes sour:

/// <summary>
/// Play audio file using response.redirect, can throw
/// </summary>
/// <param name="response">used to redirect to the created file path</param>
/// <param name="filePath"></param>
/// <param name="fileName"></param>
public static void PlayAudioFile(Page page, string filePath, string fileName) 
{        
    const string TempFolder ="tmp";
    string newPath = page.Server.MapPath(TempFolder);
    string newFileName = Guid.NewGuid().ToString() + fileName;
    System.IO.File.Copy(filePath +"\\" + fileName, newPath+"\\" + newFileName,true);
    page.Response.Redirect(TempFolder + "\\" + newFileName);
}

Thank in advance, Yuval

Was it helpful?

Solution

It took forever but I finally figured out what was the problem. The problem was this little Bugger (Get it? bugger?):

 asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"          
 EnableScriptGlobalization="true"
        EnableScriptLocalization="true"
 /asp:ToolkitScriptManager>

When I switched it to the standart everything started to work. What I, unfortunately, neglected to say is that this project is built on an older project which was migrated to VS2010 from VS2008, along with all it's binaries. I hadn't researched thoroughly, but it seems that this is caused by using an ill fitting version of the Ajax Control Toolkit. My project is .Net 4.0 and the toolkit is 3.5.

Thanks for all your time, Yuval.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top