Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Developement questions (http://www.velocityreviews.com/forums/t506693-developement-questions.html)

Lloyd Sheen 05-15-2007 02:41 PM

Developement questions
 
I have a couple of questions about URLs.

I have an app which will allow me to access my music collection if I can
access the internet.

It shows a list of Artists / Genres / Search etc which produces a GridView
list of songs each with a "Play" button. All the code works and I can play
most of the songs with no problem. It is songs with "special" characters in
the filename that cause problems. A single quote in the filename or a "\"
are examples. I am using Javascript to play the songs from a WMP embedded
object.

I used code to escape those two characters and then those files worked. Now
any files with the char "&" don't work. I tried the
System.Web.HttpUtility.HtmlEncode function but that worked worse than my
string.replace hack mentioned above. Any ideas how to resolve that in the
Dot.Net way??

Also I have a Virtual Directory pointing to my MP3 collection. I want to do
a replace on the URL created above to reference the files from the virtual
directory. I am not sure how to do that and if I do I need a method of
testing. Since I am on Vista and cannot get IIS 7 and VS 2005 Pro to talk
to each other I need a method to determine whether to do the virtual
directory replace on the URL when it is accessed thru IIS and not do it when
I am testing in the VS 2005 environment. Any ideas?

Thanks

Lloyd Sheen


Alexey Smirnov 05-15-2007 07:58 PM

Re: Developement questions
 
On May 15, 4:41 pm, "Lloyd Sheen" <a...@b.c> wrote:
> I used code to escape those two characters and then those files worked. Now
> any files with the char "&" don't work. I tried the
> System.Web.HttpUtility.HtmlEncode function but that worked worse than my


You should try the System.Web.HttpUtility.UrlEncode


Lloyd Sheen 05-15-2007 09:28 PM

Re: Developement questions
 

"Alexey Smirnov" <alexey.smirnov@gmail.com> wrote in message
news:1179259119.745487.56300@o5g2000hsb.googlegrou ps.com...
> On May 15, 4:41 pm, "Lloyd Sheen" <a...@b.c> wrote:
>> I used code to escape those two characters and then those files worked.
>> Now
>> any files with the char "&" don't work. I tried the
>> System.Web.HttpUtility.HtmlEncode function but that worked worse than my

>
> You should try the System.Web.HttpUtility.UrlEncode
>


Thanks but that did not work. I am passing the URL to a JavaScript method
which takes the URL and passes it to an embedded WMP for playing. I need to
string.replace("\","\\") and string.replace("'","\'") to get any thing to
work (that is the "\" problem) and if the file name has a "'" it will not
play as well. The UrlEncode did not change a thing so I have no idea how to
pass a URL with a file name or folder name with an "&".

Lloyd Sheen


Alexey Smirnov 05-15-2007 09:57 PM

Re: Developement questions
 
On May 15, 11:28 pm, "Lloyd Sheen" <a...@b.c> wrote:
> "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message
>
> news:1179259119.745487.56300@o5g2000hsb.googlegrou ps.com...
>
> > On May 15, 4:41 pm, "Lloyd Sheen" <a...@b.c> wrote:
> >> I used code to escape those two characters and then those files worked.
> >> Now
> >> any files with the char "&" don't work. I tried the
> >> System.Web.HttpUtility.HtmlEncode function but that worked worse than my

>
> > You should try the System.Web.HttpUtility.UrlEncode

>
> Thanks but that did not work. I am passing the URL to a JavaScript method
> which takes the URL and passes it to an embedded WMP for playing. I need to
> string.replace("\","\\") and string.replace("'","\'") to get any thing to
> work (that is the "\" problem) and if the file name has a "'" it will not
> play as well. The UrlEncode did not change a thing so I have no idea how to
> pass a URL with a file name or folder name with an "&".
>
> Lloyd Sheen


Does the "\&" {slash and amersand} help?

If not can you send an example of the generated js?


Lloyd Sheen 05-16-2007 03:19 PM

Re: Developement questions
 

"Alexey Smirnov" <alexey.smirnov@gmail.com> wrote in message
news:1179266277.601626.215000@k79g2000hse.googlegr oups.com...
> On May 15, 11:28 pm, "Lloyd Sheen" <a...@b.c> wrote:
>> "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message
>>
>> news:1179259119.745487.56300@o5g2000hsb.googlegrou ps.com...
>>
>> > On May 15, 4:41 pm, "Lloyd Sheen" <a...@b.c> wrote:
>> >> I used code to escape those two characters and then those files
>> >> worked.
>> >> Now
>> >> any files with the char "&" don't work. I tried the
>> >> System.Web.HttpUtility.HtmlEncode function but that worked worse than
>> >> my

>>
>> > You should try the System.Web.HttpUtility.UrlEncode

>>
>> Thanks but that did not work. I am passing the URL to a JavaScript
>> method
>> which takes the URL and passes it to an embedded WMP for playing. I need
>> to
>> string.replace("\","\\") and string.replace("'","\'") to get any thing to
>> work (that is the "\" problem) and if the file name has a "'" it will not
>> play as well. The UrlEncode did not change a thing so I have no idea how
>> to
>> pass a URL with a file name or folder name with an "&".
>>
>> Lloyd Sheen

>
> Does the "\&" {slash and amersand} help?
>
> If not can you send an example of the generated js?
>


Thanks, the "\&" does not work. Any file with the & either in the folder
name or file name will not play.

I have removed the UrlEncode and gone with a strictly string.replace. It
works as I said for both single quote and back slash.

I added an alert to the Javascript code and without using the UrlEncode when
I look at the Url in the WMP player it has a &amp; in the Url.


While composing this I noticed that since the name is displayed in a grid
the actual value has an &amp; in the name. I replaced this with \& and that
works.

Thanks for the help.

By the way I solved the problem of where I am executing from by using the
CurrentExecutionFilePath from the request and determining whether I am
executing from IIS or VS.

Thanks again.

Lloyd Sheen


Alexey Smirnov 05-16-2007 05:30 PM

Re: Developement questions
 
On May 16, 5:19 pm, "Lloyd Sheen" <a...@b.c> wrote:
> Thanks, the "\&" does not work.


okay, it does not work

> I replaced this with \& and that works.


Huh? It does work.

What's the diference? :-)

> I added an alert to the Javascript code and without using the UrlEncode when
> I look at the Url in the WMP player it has a &amp; in the Url.


(&amp;) is the HTML code for the ampersand symbol (&)

The URL escaped code for (&) is (%26).
This is basically what the HttpUtility.UrlEncode returns for (&).

Cheers!



All times are GMT. The time now is 07:35 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.