Forum Moderators: open

Message Too Old, No Replies

Trying to caputer URL paramter, retain part, redirect to another url

url, parameter, aspx, .net

         

scotteredu

11:53 pm on Oct 30, 2008 (gmt 0)

10+ Year Member



on the page GenerateASX.aspx I need to capture some url paramaters and then redirect the user to a new page (based off the parameter) ethier automatically, or making the user click a link on the GenerateASX.aspx page.

So incoming is [server...]

I want to capture just the 'recording1.wmv' portion of the url and bump the user to the following link:

mms://server/recording1.wmv

Most of this is out of my hands (and over my head) and I really only have a few options, one of them is changing the GenerateASX.aspx page...

Does anyone have any ideas?

ps.. it seems I can edit web.config (if that helps at all)for the site but most everything else (including the page where the URL params are coming from) are compiled into DLLS and unavailable to me.

carguy84

6:33 am on Oct 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Easy quick solution:
page_load:
Dim strShow as String = Request("show")
strShow = strShow.Replace("C:\readytoview\", "")

Response.Redirect("mms://server/" & strShow)

scotteredu

6:11 pm on Oct 31, 2008 (gmt 0)

10+ Year Member



Thanks! I will give it a try.

scotteredu

7:15 pm on Oct 31, 2008 (gmt 0)

10+ Year Member



I am hitting a wall with 'as' throws an error... ;(

I never have to do this stuff so I am way over my head. Is there a way that you could post a full formed page where this would work? Also, at the end of the URL there is a &remote=true that needs to be pulled from the filename.

Thanks for the help.

carguy84

8:02 pm on Oct 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is the page in C# or VB.NET? Are there ';' at the end of every line?

scotteredu

8:46 pm on Oct 31, 2008 (gmt 0)

10+ Year Member



The rest of the application is C# (thats what the aspx pages say at the top). I have this right now, though I dont think it matters in whether it is C# or vb (as far the server software goes.
<html>
<head>
<title>redirect</title>
<script runat="server" language="C#">
protected void Page_Load(Object s, EventArgs e)
{
Dim strShow as String = Request("show");
strShow = strShow.Replace("C:\readytoview\", "");
Response.Redirect("mms://server/" & strShow);
}
</script>
</head>

<body>
</body>
</html>

I can get the following to autoredirect - that is about as far as I got

<html>
<head>
<title>redirect</title>
<script runat="server" language="C#">
protected void Page_Load(Object s, EventArgs e)
{
Response.Redirect("http://website.com/");
}
</script>
</head>

<body>
</body>
</html>

scotteredu

9:24 pm on Oct 31, 2008 (gmt 0)

10+ Year Member



getting way closer...

<html>
<head>
<title>redirect</title>
<script runat="server" language="C#">
protected void Page_Load(Object s, EventArgs e)
{
string snpstrm = Request.QueryString["show"];
Response.Redirect("mms://server/" + snpstrm);
}
</script>
</head>

I am just testing the basic princples of the redirect... ran into a problem with AddContentType or AddHeader to make the browser know what to do with the mms links...any ideas?

Still need to cut out c:/readytoview/ before file name... ironically as I have it now, it drops the &remote=true off the end of the filename already...

<body>
</body>
</html>

scotteredu

5:17 pm on Nov 1, 2008 (gmt 0)

10+ Year Member



The following works ok. I was chasing and chasing the MMS:// link problem, where Redirect didn't give the client browser a heads up on what type of link it was. At least in IE6 and 7. Intsead IE would think that the URL was HTTP, when it wasn't. I messed with adding the right header type but I wasn't getting anywhere. On Window Media Server I was able to enable streaming over HTTP and move the port to 8080 to avoid conflicting with Port 80, already in use.

I needed how to figure out how to use .Replace but no matter what I kept getting errors from the web server. I found the .Remove function; which is based on integers/characters and it basically starts at character 0 and removes all the characters through 15 in the begining of the string, which is the 'c:/readytoview/' portion in the original URL being handed to the page in question. One odd thing is that sometimes the link coming in is actually 'c%3a%5readytoview%5c' which is more than 15 characters... but either the browser does something of ASP.NET does something and it only 'sees' it as 15 characters. If I edit the code below to 0, 21 it chops more of the string off. I need it to work unconditionally across all platforms and browsers - anyone know why the 'c%3a%5readytoview%5c' is being handled that way? I mean, if it works everytime that is fine, i just want to make sure.

<html>
<head>
<title>redirect</title>
<script runat="server" language="C#">
protected void Page_Load(Object s, EventArgs e)
{
string snpstrm = Request.QueryString["show"];
string mms = snpstrm.Remove(0,15);
Response.Redirect("http://server:8080/" + mms);
}
</script>
</head>

<body>

</body>
</html>