how to Get ID in global.asax page

H

Hemant

Hi,
I am working on a web application in vb.net 2005.
I want to get a ID of Item in Application_BeginRequest function of
global.asax file .
I can't use query string.
Is there any method ?
I want to pass a ID to that function from a .aspx page .
Please help me.

Thanks,
Hemant
 
G

Guest

Hi,
I am working on a web application in vb.net 2005.
I want to get a ID of Item in Application_BeginRequest function of
global.asax file .
I can't use query string.
Is there any method ?
I want to pass a ID to that function from a .aspx page .
Please help me.

Thanks,
Hemant

Why you can't use query string?
 
H

Hemant

Hi ,
I am not using query string because it will be display in url and I don't
want to display this ID in URL.
Thanks,
Hemant
Hi,
I am working on a web application in vb.net 2005.
I want to get a ID of Item in Application_BeginRequest function of
global.asax file .
I can't use query string.
Is there any method ?
I want to pass a ID to that function from a .aspx page .
Please help me.

Thanks,
Hemant

Why you can't use query string?
 
P

Patrice

If I remember at this step I believe session is not yet available and the
request could be something else than an ASPX page. If the problem is that
you don't want to show the value you could show a handle (a guid that would
allow to retrieve the value server side).

Whenever you have something a bit unusual your best bet is likely to explain
what is the overgoal in case someone would have another suggestion than the
solution you already choosed (for example if session you could do this in a
later event once session was made available, also knowing what you'll use
this ID for could lead to a whole different direction)...
 
G

Guest

Hi ,
I am not using query string because it will be display in url  and I don't
want to display this ID in URL.
Thanks,




Why you can't use query string?

The session is not initiated at that point, so you can try to use
cookies or a database behind. Maybe you need to explain in more
details what your application is supposed to do.
 
G

Gregory A. Beamer

Hi,
I am working on a web application in vb.net 2005.
I want to get a ID of Item in Application_BeginRequest function of
global.asax file .
I can't use query string.
Is there any method ?
I want to pass a ID to that function from a .aspx page .
Please help me.

i am not sure I understand the issue.

In code behind, you can get the session id at any time. You can then
feed it to a function and get back whatever answer you need. Why must
you do it in Application_BeginRequest (which is prior to parsing out the
information from the client, if I remember correctly)?

The big question is WHAT are you trying to solve, not HOW are you trying
to solve it now.

Peace and Grace,
 
H

Hemant

Hi ,
Thanks for your replies.
I am doing url rewriting .
In Application_BeginRequest i want to get ID's of the string.
At this function I call the Context.Rewrite Path to Redirect the correct
page
What I need that I want to store that ID some where so that I can pass that
ID to the Right page.
For Example :
My URL is www.Test.com/book-asp.html
But the actual URL for this is www.Test.com/Product.aspx?ID = 100
I want to get this ID at that function so that I can call the correct page
with correct ID.
Thanks,
Hemant
 
G

Guest

Hi ,
Thanks for your replies.
I am doing url rewriting .
In Application_BeginRequest i want to get ID's of the string.
At this function I call the Context.Rewrite Path to Redirect the correct
page
What I need that I want to store that ID  some where so that I can pass that
ID to the Right page.
For Example :
My URL iswww.Test.com/book-asp.html
But the actual URL for this iswww.Test.com/Product.aspx?ID= 100
I want to get this ID at that function so that I can call the correct page
with correct ID.
Thanks,
Hemant

Let's see what we have
My URL iswww.Test.com/book-asp.html
ok

But the actual URL for this iswww.Test.com/Product.aspx?ID= 100

ok

Now, going back to your question - what do we have in
Application_BeginRequest? We have "book-asp.html", we don't need any
querystring here because this is a new location we have to redirect
to. Am I right?
 
H

Hemant

Hi,
Yes you are right.

know at Application_BeginRequest I redirect .
I want to get that ID so that I can pass this to that page.
Thanks.
Hemant .
Hi ,
Thanks for your replies.
I am doing url rewriting .
In Application_BeginRequest i want to get ID's of the string.
At this function I call the Context.Rewrite Path to Redirect the correct
page
What I need that I want to store that ID some where so that I can pass
that
ID to the Right page.
For Example :
My URL iswww.Test.com/book-asp.html
But the actual URL for this iswww.Test.com/Product.aspx?ID= 100
I want to get this ID at that function so that I can call the correct page
with correct ID.
Thanks,
Hemant

Let's see what we have
My URL iswww.Test.com/book-asp.html
ok

But the actual URL for this iswww.Test.com/Product.aspx?ID= 100

ok

Now, going back to your question - what do we have in
Application_BeginRequest? We have "book-asp.html", we don't need any
querystring here because this is a new location we have to redirect
to. Am I right?
 
G

Guest

Hemant, I don't think you understand the problem. All what you need is
to have something like this

void Application_BeginRequest(object sender, EventArgs e)
{
string url = Context.Request.Url.AbsolutePath;

if (url.Equals("/book-asp.html"))
Context.RewritePath("/Product.aspx?ID=100", false);
}

where you don't need any query string because the requested url is
book-asp.html and not Product.aspx?ID=100.

Hope this helps
 
H

Hemant

Hi,
Thanks for reply
Here I am explain in detail what I want to do .
void Application_BeginRequest(object sender, EventArgs e)
{

Here I pass book-asp.html to DataBase to get the ID where it match the
same name book-asp.html
If in my database there are two product in different category of same name
as book-asp.html .
or If i put the same product in two category than I got the wrong categoryid
so
I want to pass that category id from previous page so that i can fetch right
product with right categoryid.
}

that's why I want to pass a ID .
hope you can understand my problem.
Thanks,
Hemant

Hemant, I don't think you understand the problem. All what you need is
to have something like this

void Application_BeginRequest(object sender, EventArgs e)
{
string url = Context.Request.Url.AbsolutePath;

if (url.Equals("/book-asp.html"))
Context.RewritePath("/Product.aspx?ID=100", false);
}

where you don't need any query string because the requested url is
book-asp.html and not Product.aspx?ID=100.

Hope this helps
 
G

Guest

Hi,
Thanks for reply
Here I am explain in detail what I want to do .
void Application_BeginRequest(object sender, EventArgs e)
{

  Here I pass book-asp.html to DataBase to get the ID where it match the
same name book-asp.html
 If in my database there are two product in different category of same name
as book-asp.html .
or If i put the same product in two category than I got the wrong categoryid
so
I want to pass that category id from previous page so that i can fetch right
product with right categoryid.

}

that's why I want to pass a ID .
hope you can understand my problem.
Thanks,
Hemant

You can try to use Request.UrlReferrer.ToString() to get referrer url
http://msdn.microsoft.com/en-us/library/system.web.httprequest.urlreferrer.aspx

But I think this could lead to a problem: when there is no referrer,
you can't identify "right" categoryid, and users may not use direct
url to that page. Search engines will have troubles with indexing...
 
H

Hemant

Hi,
Thanks for this.
As you say this is not good for search engines indexing than I don't want to
use this because all of this is only for search engin indexing.
Can you tell me that if i pass www.test.com/book-asp.html?id=100 or
www.test.com/book-asp.html?100 will make any affect to the search engin
indexing.
If this does't make any trouble than i think my search ends here if not
than i have to try more.
thanks for your support and reply.
thanks,
hemant
Hi,
Thanks for reply
Here I am explain in detail what I want to do .
void Application_BeginRequest(object sender, EventArgs e)
{

Here I pass book-asp.html to DataBase to get the ID where it match the
same name book-asp.html
If in my database there are two product in different category of same name
as book-asp.html .
or If i put the same product in two category than I got the wrong
categoryid
so
I want to pass that category id from previous page so that i can fetch
right
product with right categoryid.

}

that's why I want to pass a ID .
hope you can understand my problem.
Thanks,
Hemant

You can try to use Request.UrlReferrer.ToString() to get referrer url
http://msdn.microsoft.com/en-us/library/system.web.httprequest.urlreferrer.aspx

But I think this could lead to a problem: when there is no referrer,
you can't identify "right" categoryid, and users may not use direct
url to that page. Search engines will have troubles with indexing...
 
G

Guest

Hi,
Thanks for this.
As you say this is not good for search engines indexing than I don't want to
use this because all of this is only for search engin indexing.
Can you tell me that if i passwww.test.com/book-asp.html?id=100orwww.test.com/book-asp.html?100will make any affect to the search engin
indexing.
If this does't make any trouble than i  think my search ends here if not
than i have to try more.
thanks for your support and reply.
thanks,




You can try to use Request.UrlReferrer.ToString() to get referrer urlhttp://msdn.microsoft.com/en-us/library/system.web.httprequest.urlref...

But I think this could lead to a problem: when there is no referrer,
you can't identify "right" categoryid, and users may not use direct
url to that page. Search engines will have troubles with indexing...- Hide quoted text -

- Show quoted text -

If all this was for SEO, then you can leave it as it is. While Static
URLs might have a slight advantage, Google and other major SE do not
have any problems to index dynamic links, especially when you have
just "page.aspx?id=100". Having ".html" instead of ".aspx" will not
help too. If you definitely need it, you can consider one of the
following links

/Product100.aspx
/100.aspx
/100/Book.aspx
/Product.aspx/100

Each link would work for well for users and SEO
 
G

Gregory A. Beamer

Hi ,
Thanks for your replies.
I am doing url rewriting .
In Application_BeginRequest i want to get ID's of the string.
At this function I call the Context.Rewrite Path to Redirect the
correct page
What I need that I want to store that ID some where so that I can
pass that ID to the Right page.
For Example :
My URL is www.Test.com/book-asp.html
But the actual URL for this is www.Test.com/Product.aspx?ID = 100
I want to get this ID at that function so that I can call the correct
page with correct ID.
Thanks,
Hemant

The norm to URL rewrite is using an HTTP Handler rather than trying to
write it in your ASP.NET application. There are plenty of web pages that
describe setting up this type of URL rewrite.

If you can go to 3.5 SP1, you can also use URL Routing, which will also
be a part of .NET 4.0.

Peace and Grace,
 
G

Guest

The norm to URL rewrite is using an HTTP Handler rather than trying to
write it in your ASP.NET application. There are plenty of web pages that
describe setting up this type of URL rewrite.

If you can go to 3.5 SP1, you can also use URL Routing, which will also
be a part of .NET 4.0.

Peace and Grace,

in this case I would suggest IIS 7 which has URL Rewrite module
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top