Web server instances? - asp.net

Very newbie question, please forgive me:
I'm creating an asp.net website. I assume that when multiple people request the page each person gets a new instance of the site. However, if the site uses a .jpg image on the server and manipulates the image, does each person get an instance of the image also, or do they share the image somehow? I think I know, and that this is probably a dumb question, but I wanted to ask.
As an example: A user logs into the site, and adds times to a schedule. Depending on the schedule, a blue line is drawn on an image (grid.jpg), which depicts a daily timeline. The image is then saved as newgrid.jpg and displayed to the user. Is there a way for each user to get an instance of the image that only they can see?

A great way to generate dynamic images in ASP.NET is by using a Handler. The answer over here offers a good, simple example. In this scenario, the generated image never touches the local file system, it's just generated in memory, and returned to the client.

Well, usually the site is always the same for all users, but there are sessions created for each user with specific settings that you can set. So yes, all people will by default see the same changes (and the same content).

Related

Other users seeing a 3rd party website with same user stylesheet

I have a group of users that will be using a web database.
Ideally, I would like these users to view that website with some user styles of our creation (so that some of the website elements are displayed differently, like highlighting fields they need to fill out). These users are independent and remote, meaning that we can't really access their computers to do anything to set this up (like setting up Stylish for them).
I was wondering if we could somehow create a package that will display the website using such stylesheet, as if it was an application rather than a website that they visit with their browser.
The idea would be that by opening this "app" they're actually opening a dedicated browser window to this webpage where they can interact with it, can't navigate away (just no address bar), and uses this stylesheet I mentioned. Thus the "as if it was an app".
I hope I was sufficiently clear. I don't even know what this would be called (not even what tags to use), so my research has really taken me nowhere. Guidance on how to get this done will be highly appreciated. If somebody has a better idea of how to obtain a similar result, I'll be happy to experiment!!
Thanks!
Will the users be logging in through user accounts in your database?
If so, create a column in the user database which, should it return a certain value (say true for these special users and false for all else) then a different stylesheet is used.

optimize and best practice for image call each time

I have client code for large project, their logo is on master page, which he updates weekly.
I have to update the title, image path, etc. on all the server and also upload a new image on all servers, now he wants to automate this process.
What is the best way to accomplish this? I have thought about storing the information (including Image) in database with single record and each time client update this single record when they want. But on each page, the logo image will come from database. Is it ok or should we cache or some other option to reduce load each time? Can we update page(.aspx) file using filestream like we can update text file? because if I update aspx from code then we don't have call any SQL, just upload an image, update the title and other information in aspx page.
Very simple. If the client wants to update something on their own without requiring developer intervention, it needs to go in the database. You can of course add any caching or whatever you like so that it's not necessary to query the database each request.
The only other viable alternative would be giving the client access to the directory that has the logo and insist on a convention for the logo filename. The client can then simply upload a new logo with the same filename and nothing needs to change on the site.
Making changes to the page itself automatically is a hugely bad idea. Avoid that like the plague.
I suppose a final though not bloody likely option is to get the client to realize that a logo shouldn't freaking be changed weekly or even yearly. It's a freaking logo; it's your identifying mark to the public.

asp.net url concealment?

In my asp.net 2005 app, I would like conceal the app structure from the user. Currently, the end user can learn intimate details of my web app as they navigate and watch the url change. I don't want the end user to know about my application structure. I would like the browser url to not change if possible. Please advise.
thanks
E.A.
URL rewriting is the only one that can provide any kind of real concealment.
Just moving the requests to AJAX or to frames, means anyone (well, more advanced users) can still see those requests being fired, just not in the address bar.
Simplest solution is to use frames - a single frame that holds your application and is 100% * 100%. The URL will not change though the underlying URL can still be seen via "View Frame info", however only advanced users will even figure that out.
In your pages, make sure that they are contained inside the holding frame.
A couple of possibilities.
1) use AJAX to power everything. This will mean that the user never leaves the home page
2) use postbacks to power everything. In this, you'd have all those pages be user controls which you progrmattically hide or show.
3) URL rewriting (especially if this is asp.net 3.0 or later)
My site uses url parameters to dynamically load ascx files into a single main aspx. So if I get 'page_id=123' on the query string, I load the corresponding ascx. The url changes, but only the query string - the domain part remains the same.
If you want the url to remain precisely the same at all times, then frames (per Oded) or ajax (per Stephen) are probably the only ways to do it.
Short answer: use URL encryption
A simple & straight article: http://devcity.net/PrintArticle.aspx?ArticleID=47
and another article: https://web.archive.org/web/20210610035204/http://aspnet.4guysfromrolla.com/articles/083105-1.aspx
HTH

Can I programmatically tell when a new tab is opened in the browser?

I'm addressing a problem with an ASP .NET web application where I want to avoid using query strings to uniquely identify dynamic content. I want to index the content relative to the opened tab/window that is displaying it. Is this programmatically possible? If so, what is the compatibility of the approach across multiple browsers? Thank you for your help.
No. It's not really any different to the user opening a new browser window, or opening the calculator application to work something out, etc. It happens outside the context of your web page and, short of a browser plugin, you can't get notification of this.
No, it's not possible by "tab" (i.e., browser window instance).
The closest you'll get is to drive new page requests off of session data established in previous requests but that's really a far cry from what you're asking asking for.
I'd tell whomever is "tasking" you with this that they are a moron you can't change the fundamental communication protocols of the web.

Using ASP.Net, is there a programmatic way to take a screenshot of the browser content?

I have an ASP.Net application which as desired feature, users would like to be able to take a screenshot. While I know this can be simulated, it would be really great to have a way to take a URL (or the current rendered page), and turn it into an image which can be stored on the server.
Is this crazy? Is there a way to do it? If so, any references?
I can tell you right now that there is no way to do it from inside the browser, nor should there be. Imagine that your page embeds GMail in an iframe. You could then steal a screenshot of the person's GMail inbox!
This could be made safe by having the browser "black out" all iframes and embeds that would violate cross-domain restrictions.
You could certainly write an extension to do this, but be aware of the security considerations outlined above.
Update: You can use a canvas utility function to get a screenshot of a page on the same origin as your code. There's even a lib to allow you to do this: http://experiments.hertzen.com/jsfeedback/
You can find other possible answers here: Using HTML5/Canvas/JavaScript to take screenshots
Browsershots has an XML-RPC interface and available source code (in Python).
I used the free assembly UrlScreenshot.dll which you can download here.
Works nicely!
There is also WebSiteScreenShot but it's not free.
You could try a browser plugin like IE7 Pro for Internet Explorer which allows you to save a screenshot of the current site to a file on disk. I'm sure there is a comparable plugin for FireFox out there as well.
If you want to do something like you described. You need to call an external process that prints the IE output as described here.
Why don't you take another approach?
If you have the need that users can view the same content over again, then it sounds like that is a business requirement for your application, and so you should be building it into your application.
Structure the URL so that when the same user (assuming you have sessions and the application shows different things to different users) visits the same URL, they always see same thing. They can then bookmark the URL locally, or you can even have an application feature that saves it in a user profile.
Part of this would mean making "clean urls", eg, site.com/view/whatever-information-needed-here.
If you are doing time-based data, where it changes as it gets older, there are probably a couple possible approaches.
If your data is not changing on a regular basis, then you could make the "current" page always, eg, site.com/view/2008-10-20 (add hour/minute/second as appropriate).
If it is refreshing, and/or updating more regularly, have the "current" page as site.com/view .. but allow specifying the exact time afterwards. In this case, you'd have to have a "link to this page" type function, which would link to the permanent URL with the full date/time. Look to google maps for inspiration here-- if you scroll across a map, you can always click "link to here" and it will provide a link that includes the GPS coordinates, objects on the map, etc. In that case it's not a very friendly url but it does work quite well. :)

Resources