Computer Science Canada

ASP server help, (n00b question)

Author:  mirhagk [ Wed Dec 08, 2010 9:36 pm ]
Post subject:  ASP server help, (n00b question)

While using ASP, is it possible to have one server page retrieve all the URL's for a site, and then dynamically generate web pages based on the URL (for instance im testing out making a picture hosting server, can the server get all URL requests for the site, and then create an HTML page with the correct picture based on what the URL is, basically check it against file names)

EDIT: found an easier way with this specific example, but how about in general, can I?

Author:  Dan [ Thu Dec 09, 2010 6:01 am ]
Post subject:  RE:ASP server help, (n00b question)

Not 100% sure what you mean by "have one server page retrieve all the URL's for a site" and "can the server get all URL requests for the site".

If you mean can you take a url request like "http://compsci.ca/v3/viewtopic.php?p=26811" or "http://compsci.ca/v3/viewtopic.php?t=3151" and have them give diffrent content to user viewing the site in a brower or by other means dispite them both calling the same script/application (viewtopic.php), then yes you can.

Noramly you would not generate a html document and store it on the server (unless you are doing some kind of caching), but rather generate the html output and send it to the user based on thier request.

In the example i gave one request asks for the topic by the id of 26811 (this topic) and one ask for the topic by the id of 3151 (the rules topic). However both cause the same script to run on the server but with diffrent paramaters and give diffrent results to the end user.


Edit: If you just want to make a simple image hosting site, then you proably don't even need to make an application or script to serve the image files by name as thats what a web server is for. You may however need to make the upload script.

Author:  DIIST [ Thu Dec 09, 2010 3:17 pm ]
Post subject:  Re: ASP server help, (n00b question)

Yes as Dan mentioned, you can have different URL point to the same aspx file by injecting parameters into the URL.

Say you have two different URLs :
http://www.mywebpage.com/pic.aspx?img=cat&width=640&height=480
http://www.mywebpage.com/pic.aspx?img=dog&width=320&height=240

You can access the parameters like so:

code:

String imageName = Request["img"];

//or

String imageName = Request.QueryString("img");


If you want to generate images make sure to change the content type so that your image does not appear as a byte array to the browser.

This article might help.

http://blogs.msdn.com/b/jrule/archive/2004/08/16/215393.aspx

I assume your using ASP.net. ASP is really outdated :/.

Author:  mirhagk [ Thu Dec 09, 2010 3:34 pm ]
Post subject:  RE:ASP server help, (n00b question)

THank you diist, actaully my end goal is in fact to create a forum like website, and my example was a poor one. Yes that's what I meant having the webpage with ?var=213 or whatever at the end, and how to actually read that. Thanks.


next goal is reading XML files, (I know there is a way to easily do it, I used javascript with DOM before, so just gotta find out exactly what it is). Tested out the variable thing, and it works splendidly, now just gotta store everything as an xml file, and the work is half done (also found oswd.org where they give amazing css templates out for free, so the formatting can easily be handled by css style sheets)

Author:  Dan [ Thu Dec 09, 2010 4:14 pm ]
Post subject:  Re: RE:ASP server help, (n00b question)

mirhagk @ 9th December 2010, 3:34 pm wrote:

next goal is reading XML files, (I know there is a way to easily do it, I used javascript with DOM before, so just gotta find out exactly what it is). Tested out the variable thing, and it works splendidly, now just gotta store everything as an xml file, and the work is half done (also found oswd.org where they give amazing css templates out for free, so the formatting can easily be handled by css style sheets)


That sounds like a rather bad idea.

You will want to store the posts in a realtion database mangment system (DBMS) of some kind. Examples include MySQL (free open source), PostgreSQL (free open source) or MS Access (only if you want to countione your support for poorly made closed source products).

Realtion databases will make your job much easier and will manage concurrency issues for you.

I also recomend looking to see if their are any web frameworks for ASP.NET (if you must use ASP) that handel sanitization of sql queries and html to help with security issues, make simple quries for you and allow for rapid protyping and design.

Author:  mirhagk [ Thu Dec 09, 2010 10:55 pm ]
Post subject:  RE:ASP server help, (n00b question)

Okay so where do I learn how to use SQl tables with ASP.net

Author:  Dan [ Thu Dec 09, 2010 11:38 pm ]
Post subject:  RE:ASP server help, (n00b question)

Well once you decied on what DBMS you will be using you could just google it.

For example for mysql:

http://lmgtfy.com/?q=ASP.net+mySQL+tutorial&l=1

Author:  mirhagk [ Wed Dec 15, 2010 8:21 am ]
Post subject:  RE:ASP server help, (n00b question)

Okay just to double check, if i check request for variable that wasn't given, it just returns nothing right? And how do I pass multiple variables, arethey comma seperated?

EDIT: Went to google and looks like it's default.aspx?var1=foo&var2=fal

is that right?


: