Eduardo Lorenzo
04-05-2007, 12:01 PM
Ok this is the situation:
I have say, a landing page with a few links in a dynamically populated list. Each link of course points to a unique page. What I want to do is, place each unique page in their individual folders and then place all these folders into one (parent) folder.
And then I want the landing page links point to the parent folder and then the name of the induvidual folder. How would I be able to parse the url and convert it to a querystring?
Something like this:
1. UniquePage1.aspx is waiting for string "unique1" and is placed in folder "Unique1"
2. UniquePage2.aspx is waiting for string "unique2" and is palced in folder "Unique2"
3. both folders Unique1 and Unique2 are placed in folder "UniquePages"
4. The landing page will issue this:
Response.Redirect("UniquePages/Unique1")
5. UniquePages folder will have a Default.aspx file which will have the code:
Response.Redirect("~/UniquePages/Unique1/Default.aspx?lookforme=unique1") <-- how do I construct this string?
MKoslof
04-05-2007, 05:20 PM
Folders are just virtual directories to your web application. There is nothing stopping you from having a Parent virtual directory that has child directories underneath. I assume you are creating your virtual directories at design time or it is in place prior to deployment.
I don't understand what you are trying in do in relation to the query string. What is "Unique1" supposed to be? A just some string value or another form or directory? Why do you need to pass a directory or url via a querystring?
Eduardo Lorenzo
04-06-2007, 07:20 AM
Unique1 is the name of the folder
UniquePage1 is the name of the aspx file
unique1 is the querystring variable name.
what I basically want is for the parent page(landing page) to issue Response.Redirect("~/UniquePages/Unique1") and then Default.aspx located in that folder will issue Response.Redirect("~/UniquePages/Unique1/Default.aspx?lookforme=unique1") where unique1 is converted from the foldername.
So if the landing page issues Response.Redirect("~/UniquePages/Unique2"), Default.aspx in UniquePages will issue Response.Redirect("~/UniquePages/Unique2/default.aspx?lookforme=unique2")
MKoslof
04-06-2007, 01:41 PM
Do you have current code that isn't working? Maybe if you post what you have, I will better understand what you are trying to do, since in all honesty, I don't follow :).
I'm not understanding the "lookforme" query string parameter. A query string parameter is just that, a string value you can read or access from a given entity. You are passing the value of "unique1" or "unique2". So in the target form you can read the lookforme query string value and resolve that value. Once you have that value, what do you need to do?
If lookforme = "unique2" do something....
If lookforme = "unique1" do someting.....
You can Server.Transfer or Response.Redirect in the form load() event of another page, but I'm struggling to get the concept here.
Eduardo Lorenzo
04-06-2007, 01:51 PM
I know it is very strange. And borderlines on violating good programming practice.
The project is a catalog site. And the products have their own categories. Each category has its own folder and each folder has its own Default.aspx.
All product category folders are stored in the Categories folder.
The project or course has its own Default.Aspx at the root level. this page displays ALL products as objects with objcategory as part of the properties of the product. So composing the url would be somthing like
strURL = Server.MapPath + Product.objCategory
which would be passed to a Redirect command
Response.Redirect(strURL) which, woul be equal to:
Response.Redirect("~/UniquePages/Unique2")
So what I am planning is to place a Default.aspx in the UniquePages folder that gets the string "Unique2" and constructs(and then issues)
Response.Redirect("~/UniquePages/Unique2/default.aspx?lookforme=unique2")
MKoslof
04-06-2007, 02:03 PM
OK, lets go from here:
Response.Redirect("~/UniquePages/Unique2")
You invoke this call and it redirects to a Virtual directory called UniquePages which has a sub DIRECTORY called Unique2?
So upon calling that response redirect this form is supposed to be OPENED?:
"~/UniquePages/Unique2/default.aspx"
And then the query string parameter "lookforme" is passed to this page with the LITERAL STRING value of "unique2".
Now in the form load() event of "~/UniquePages/Unique2/default.aspx" you can read the query string "lookforme" and get the value "unique2". Now that you have the literal string value "unique2" in the form load event what do you need to do?
Eduardo Lorenzo
04-06-2007, 02:53 PM
Response.Redirect("~/UniquePages/Unique2")
You invoke this call and it redirects to a Virtual directory called UniquePages which has a sub DIRECTORY called Unique2?
Correct
So upon calling that response redirect this form is supposed to be OPENED?:
"~/UniquePages/Unique2/default.aspx"
not exactly, "~/UniquePages/Default.aspx" is the one supposed to be opened.
And this Default.aspx page is the one that will issue
"~/UniquePages/Unique2/default.aspx?lookforme=unique2"
my appologies for the nauseating traversal of my site's file system. AND for my command(or lack thereof) of the english language.
wayneph
04-06-2007, 02:53 PM
Every time I've heard someone implementing a solution like this, they don't actually set up separate folders. That is a ton of extra work. They have a single page that handles all objects.
When the user requests, www.yoursite.com/unique2, you set up a custom page to handle 404 errors. That page looks at the requested directory, and sends you to the catalog page with the proper id.
If you're going to send the page to a default page in Unique2, why not send it directly to the correct page? That many extra redirects is a burder on both the client and the server.
Eduardo Lorenzo
04-06-2007, 03:00 PM
It is because the url is composed using one of the properties of the object clicked on the page. (See post #5) The object is a repeater control with an imagelink.
I have planned on using separate folders for each category because each category is so complicated(to me) that it is like its own separate website.
Another thing is, www.yoursite.com/unique2/default.aspx will need to receive a parameter for the subcategory and there are between 4 and 37 sub-categories per category. :(