473,794 Members | 2,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic web pages using VirtualPathProv ider


I am creating dynamic web pages according to the user inputs from a web
page.

For instance, a user typed in a text, I would want the text being the
source code of the dynamic page.

My question is: How could I access session variables from class that
derives from VirtualPathProv ider or VirtualFile or the control values of
previous web page?

I could not use query string or cookies due to the amount of the data.

I am using HostingEnvironm ent to retrieve application path information.
I guess there are some similar global instance that I might be able to
use to retrieve information for the request.
Thanks

Charles Zhang
Jun 15 '07 #1
5 2866
Hi Charles,

The session is provided by the System.Web.Sess ionState.Sessio nStateModule
as one of the http modules pipeline. However, a VirtualPathProv ider or
VirtualFile is called at page compilation stage, at which moment the
modules are not initialized yet. Therefore you will not be able to use
Session in VirtualPathProv ider or VirtualFile.

Why not use HttpContext.Cur rent.Items to pass the information? Normally
it's used to pass data between different http modules, but I think you can
also use it to pass data to the dynamic web page.

Hope this helps.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 15 '07 #2
I think HttpContext.Cur rent.Items will do the trick for me? However, how
could I deal with thread issue or do I need to worry about threading at all?

One thing I can think is to use a application variable flag to indicate
if some other session is trying to access HttpContext.Cur rent.Items. I
guess you might know better ways.

Thanks
Walter Wang [MSFT] wrote:
Hi Charles,

The session is provided by the System.Web.Sess ionState.Sessio nStateModule
as one of the http modules pipeline. However, a VirtualPathProv ider or
VirtualFile is called at page compilation stage, at which moment the
modules are not initialized yet. Therefore you will not be able to use
Session in VirtualPathProv ider or VirtualFile.

Why not use HttpContext.Cur rent.Items to pass the information? Normally
it's used to pass data between different http modules, but I think you can
also use it to pass data to the dynamic web page.

Hope this helps.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 15 '07 #3
Just more details about what I am planning to do.

Each session will only have one item in HttpContext.Cur rent.Items.
Therefore, the session ID will be the key for the item.

I embedded the session ID into the file name of dynamic page request so
that I can retrieve the session ID then retrieve the value I stored in
HttpContext.Cur rent.Items.

A number of sessions might add new items, retrieve items from
HttpContext.Cur rent.Items at the same time (Of course with different
keys), do I need to worry about concurrent access issue from different
threads or the threading issue is handled inside the directory object?

Thanks

Charles Zhang
Charles Zhang wrote:
I think HttpContext.Cur rent.Items will do the trick for me? However, how
could I deal with thread issue or do I need to worry about threading at
all?

One thing I can think is to use a application variable flag to indicate
if some other session is trying to access HttpContext.Cur rent.Items. I
guess you might know better ways.

Thanks
Walter Wang [MSFT] wrote:
>Hi Charles,

The session is provided by the
System.Web.Ses sionState.Sessi onStateModule as one of the http modules
pipeline. However, a VirtualPathProv ider or VirtualFile is called at
page compilation stage, at which moment the modules are not
initialized yet. Therefore you will not be able to use Session in
VirtualPathPro vider or VirtualFile.

Why not use HttpContext.Cur rent.Items to pass the information?
Normally it's used to pass data between different http modules, but I
think you can also use it to pass data to the dynamic web page.

Hope this helps.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

============== =============== =============== ======
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============== =============== =============== ======

This posting is provided "AS IS" with no warranties, and confers no
rights.
Jun 15 '07 #4
Hi Charles,

The HttpContext.Cur rent is per-request, which means every worker thread has
its own Items collection; therefore different request/session will have
their own HttpContext.Cur rent. If you spawn a new background thread from
the worker thread that is currently handling the request, the background
thread will not have this HttpContext.Cur rent.

This also means a second request issued by the same user/session will also
have an brand new HttpContext.Cur rent. This is different from how session
state works across different requests. From your previous code, it seems
you're only saving the state at the beginning of each request and use it
from the dynamic web page, that's why I suggested to use it; otherwise it
will not work if you need to access previous state in
VirtualPathProv ider/VirtualFile.

Following are some reference articles you may find useful on
HttpContext/CallContext:

#Working With HttpContext.Cur rent
http://www.odetocode.com/Articles/112.aspx
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 18 '07 #5
Hi Charles,

Let me know if you have further questions. Thanks.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 21 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1489
by: only_me | last post by:
Not a coding question as such but highly related to asp/dynamic pages issues : has anyone any suggestions on the following ASP sites are generally (always) of a dynamic nature, pages can be built on the contents of querystrings, so search engines can only be directed to your first index.asp page since the search engine is unable to deduce what querystring parameters should/could be used. I have a company listing site and would like...
3
4270
by: K.S.Liang | last post by:
Hi all, 1> If there are more than one dynamic linking libraries in the file system, how do I know which one is loaded into system? Any C library or system call can tell me which *.so or *.sl is active? Can the setting of LD_LIBRARY_PATH guanrantee that the correct one is executed? 2> In MS-WINDOWS, once a DLL is loaded by one allication, this DLL will be used by the subsequent appication. Does UNIX have the same
8
2257
by: Sandy Pittendrigh | last post by:
I have a how-to-do-it manual like site, related to fishing. I want to add a new interactive question/comment feature to each instructional page on the site. I want (registered) users to be able to add comments at the bottom of each page, similar to the way the php, mysql, apache manuals work. PUNCHLINE_A:
0
1557
by: Kenny | last post by:
Help...wimper.. been trying to get a virtualpathprovider to work and I have to be missing something. I want users to be able to enter something like mydomain.com/userentereddirectory/ and have that serve up a file. So I use vpp to code up an initialization even, virturalfile, virtualdirectory and virtualpath provider. I have a simple file for testing testing.aspx (no codebehind) that just sets a label to 'hello world' on pageload. Now...
0
1382
by: Pavel Kocar | last post by:
Hi all, how to detect existing .ascx control in Net 2.0? I try to use method in VirtualPathProvider: HostingEnvironment.VirtualPathProvider.FileExists("~/App_UserControls/ucDataPager.ascx"); it return true if file ucDataPager.ascx control exists, but if I publish web site (no editable) and .ascx files not available on the disc, this method return false, its bug?
10
4939
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're called, an example of what I have in mind is index.php?page=). However, I can not figure out how to do this. I will eventually want to use SEF urls, but for now I'll be content just to have the dynamic urls. If anyone can tell me how to do this, I'd...
5
3177
by: pittendrigh | last post by:
There must be millions of dynamically generated html pages out there now, built by on-the-fly php code (and jsp, perl cgi, asp, etc). Programatic page generation is transparently useful. But querying a database, negotiatinig lots of if-then-else logic and echo'ing html code out on port 80 every time a page is requested has to be a huge waste of resources. Why not use that logic to print static html instead of dynamic?
1
1687
by: VV | last post by:
I've created virtualpathprovider class in my application. Everything is ok in developer enviroment (asp.net dev server), but when I switch to IIS everything crashes with Server 500 and 404 error. Please, what I'm missing?! VV
9
2986
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I got the core of the javascript from here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm I noticed in the demo that sometimes the content takes a long
0
10435
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.