Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Thursday, March 29, 2012

Please explain what "Empty path has no directory" means with Server.MapPath

Hello,

I have the following line of code in a script...

litMsg.Text = Server.MapPath("/");

where litMsg is an ASP.Net Literal control. When I try and run this
page, I get the error ...

System.ArgumentException: Empty path has no directory.

Anyone any idea what this means? I have used Server.MapPath many times
before without error, I'm not sure why it suddenly stopped working here.

I'm sure I'm missing something blindingly obvious and would be grateful
if anyone could point it out!! TIA.

--
Alan Silver
(anything added below this line is nothing to do with me)IN case it's of any use to anyone, I found out that the problem was
caused by me having the following two lines in Page_Load...

HttpContext myContext = HttpContext.Current;
myContext.RewritePath("/");

I'm not actually sure *why* I had those lines there, they must have been
from something I was doing before. As soon as I removed them, the
Server.MapPath worked fine.

If anyone has an explanation, I would like to hear it ;-)

>Hello,
>I have the following line of code in a script...
>litMsg.Text = Server.MapPath("/");
>where litMsg is an ASP.Net Literal control. When I try and run this
>page, I get the error ...
>System.ArgumentException: Empty path has no directory.
>Anyone any idea what this means? I have used Server.MapPath many times
>before without error, I'm not sure why it suddenly stopped working here.
>I'm sure I'm missing something blindingly obvious and would be grateful
>if anyone could point it out!! TIA.

--
Alan Silver
(anything added below this line is nothing to do with me)

Monday, March 26, 2012

Please Help - WEB Application

Hi Everyone,

I have a VB script (.aspx) project that needs to produce nine unique,
randomly generated numbers that uses all nine of the numbers. I will greatly
appreciate either a recommendation of where to look on the web for my
answer, or your direct response.

Thanks a 1,000,000 for your ideas.
ChuckChuck Insight wrote:
> Hi Everyone,
> I have a VB script (.aspx) project that needs to produce nine unique,
> randomly generated numbers that uses all nine of the numbers. I will greatly
> appreciate either a recommendation of where to look on the web for my
> answer, or your direct response.
> Thanks a 1,000,000 for your ideas.
> Chuck

If I understand correctly, you want to generate a nine-digit
"random" code that uses all of the digits in 123456789.
(what about "0"?)

What you can do is
1) start with "123456789"
2) generate two random numbers from 0 to 8 (inclusive)
3) exchange the digits at those positions
4) repeat steps 2) and 3) a dozen times.

To generate a random number, see the System.Random class
(create *one* instance, then repeatedly get random numbers
from that class)

To generate nine of these codes, use this repeatedly
but check if you already have this particular code. If
yes, discard this code and generate again.

--
Hans Kesting

Saturday, March 24, 2012

Please Help - WEB Application

Hi Everyone,
I have a VB script (.aspx) project that needs to produce nine unique,
randomly generated numbers that uses all nine of the numbers. I will greatly
appreciate either a recommendation of where to look on the web for my
answer, or your direct response.
Thanks a 1,000,000 for your ideas.
ChuckChuck Insight wrote:
> Hi Everyone,
> I have a VB script (.aspx) project that needs to produce nine unique,
> randomly generated numbers that uses all nine of the numbers. I will great
ly
> appreciate either a recommendation of where to look on the web for my
> answer, or your direct response.
> Thanks a 1,000,000 for your ideas.
> Chuck
>
If I understand correctly, you want to generate a nine-digit
"random" code that uses all of the digits in 123456789.
(what about "0"?)
What you can do is
1) start with "123456789"
2) generate two random numbers from 0 to 8 (inclusive)
3) exchange the digits at those positions
4) repeat steps 2) and 3) a dozen times.
To generate a random number, see the System.Random class
(create *one* instance, then repeatedly get random numbers
from that class)
To generate nine of these codes, use this repeatedly
but check if you already have this particular code. If
yes, discard this code and generate again.
Hans Kesting