PDA

View Full Version : File Link Issue


icelator
03-26-2009, 10:46 PM
I am creating a page with a program called sitefinity.

I am using the player mentioned here http://codingforums.com/showthread.php?t=50666

I posted on the forums for sitefinity but I figured I'd see if anyone here is able to help (http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-caacdh.aspx)

The file selector returns ~/files/video.mpg

the original problem was that when the file is used on a child page (or a page in a different folder) the url gets messed up

the proper address is www.mysite.com/files/video.mpg
The page that's loading it is www.mysite.com/parentpage/page.aspx
but the address that gets generated is www.mysite.com/parentpage/files/video.mpg

someone suggested adding
VirtualPathUtility.ToAbsolute(VidURL) instead of VidURL in the code
this worked for when I ran the site locally but when I go to another machine and access the site in my IIS folder the problem returns.

The url where the file is kept: http://192.168.0.100/Prototype1/Files/Video.mpg

prototype1 is where the website is

The url that the other computer got for the video is:

http://192.168.0.100/Prototype1/Media/Prototype1/Files/Video.mpg


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.ComponentModel;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Telerik.Cms.Web.UI;
using System.ComponentModel;
using Telerik.Web.UI;

public partial class WebUserControl : System.Web.UI.UserControl
{
private string VidURL,VidHeight,VidWidth;

[WebEditor("Telerik.FileManager.UrlWebEditor,Telerik.FileManager")]
[Category("Video Settings")]
public string VideoURL
{
get
{

return VidURL;
}
set
{
VidURL = value;
}
}
[Category("Video Settings")]
public string VideoHeight
{
get
{
return VidHeight;
}
set
{
VidHeight = value;
}
}
[Category("Video Settings")]
public string VideoWidth
{
get
{
return VidWidth;
}
set
{
VidWidth = value;
}
}

protected void Page_Load(object sender, EventArgs e)
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;

if (Session["mobile"] == "true")
{
test.InnerHtml = "This feature has been disabled for Mobile Browsers";
}
else if (browser.Type.StartsWith("IE"))
{
test.InnerHtml = "<object width='" + VidWidth + "' height='" + VidHeight + "' id='Player1' classid='CLSid:6BF52A52-394A-11d3-B153-00C04F79FAA6' ><param name='URL' value='" + VirtualPathUtility.ToAbsolute(VidURL) + "' /> <param name='autostart' value='true' /><param name='stretchToFit' value='true' /><param name='AutoRewind' value='true' /><param name='uiMode' value='full'/><param name='Volume' value='50'/></object>";
}
else
{
test.InnerHtml = "<object id='Player' type='application/x-ms-wmp' width='" + VidWidth + "' height='" + VidHeight + "' runat='server'> <param name='url' value='" + VirtualPathUtility.ToAbsolute(VidURL) + "' /> <param name='autostart' value='true' /> <param name='AutoRewind' value='true' /></object>";
}
}
}

icelator
03-27-2009, 12:47 AM
I managed to solve the problem:

string x = Request.Url.ToString();
string y = Request.Path;
x = x.Replace(y, "");
x = x + VirtualPathUtility.ToAbsolute(VidURL);
Request.Url.ToString gives full address (www.mysite.com/folder1/page.aspx)
Request.path gives the relative address of current page(/folder1/page.aspx)
x = x.Replace(y, ""); gets (www.mysite.com)
VirtualPathUtility.ToAbsolute(VidURL); gets /files/video.mpg
x = x + VirtualPathUtility.ToAbsolute(VidURL); gives the full address for the video www.mysite.com/files/video.mpg

therefore giving a hardcoded address that works no matter what the www.mysite.com actually is