simulate virtual directory for each user

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amir Eshterayeh

    simulate virtual directory for each user

    Dear Friends

    Would you please give me your professional idea about this asp.net problem.

    I need different virtual directory for different customer with their names
    like these:




    I have a asp.net project. It is a website and the content of it WebPages
    comes from database.
    To give each user a virtual directory, I have 2 options:
    1. create a virtual directory for each user and copy the asp.net project to
    each directory
    This is not a good solution.
    2. Copy all the files to root directory (www.oursite.com) and when users
    type
    www.ourwebsite.com/jack or www.ourwebsite.com/sue, I can figure out the name
    (jack or sue) and get the id of the user from database and bring the content
    of that user's web pages from database.

    I put the following code into Application_Beg inRequest event in Global.asax
    file:

    dim sFolderName As String = Request.Applica tionPath.ToStri ng.Trim("/")
    dim AgentID as long = GetAgentIdByFol derName(sFolder Name) 'from the
    database
    WriteAgentIdToC ookie(AgentID)
    Server.Transfer ("AgentHomePage .aspx")

    After writing the agent Id to client's cookie, I redirect to agent home page
    and at this page, I read cookie and get agent id and bring the agent info
    like its picture URL and home page info from database.

    The problem is: When I type : www.oursite.com/Jack
    I faced this error: page can not be found!

    Do you think global.asax is a good place to put this code? and also this
    code: Request.Applica tionPath ? HttpRequest or something?
    Is there a better way to get what user typed I mean the folder name that
    comes after my website.

    I got web hosting service from another company so I do not have any control
    over that company's IIS. I could not found a way in its web hosting's admin
    site to set the default page. Any page with default or index name will come
    when I type www.oursite.com without including file name.

    Please help. Thank you very much in advance

    Best Regards
    Andy Eshtry




  • Scott M.

    #2
    Re: simulate virtual directory for each user

    Could you be more specific as to why each user needs their own directory?
    What would "Jack" get that requires him to have a different directory than
    "Sue" or "Tom"?

    I ask because ASP.NET can build content on the fly. Content can be cached
    based on an url parameter (i.e. the user) so that different users get
    different output. And, there are many more options to ensure that different
    users to a site get different results.


    "Amir Eshterayeh" <aeshterayeh@ho tmail.com> wrote in message
    news:%23ypqklf6 DHA.2656@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > Dear Friends
    >
    > Would you please give me your professional idea about this asp.net[/color]
    problem.[color=blue]
    >
    > I need different virtual directory for different customer with their names
    > like these:
    > www.oursite.com/Jack
    > www.oursite.com/Sue
    > www.oursite.com/Tom
    >
    > I have a asp.net project. It is a website and the content of it WebPages
    > comes from database.
    > To give each user a virtual directory, I have 2 options:
    > 1. create a virtual directory for each user and copy the asp.net project[/color]
    to[color=blue]
    > each directory
    > This is not a good solution.
    > 2. Copy all the files to root directory (www.oursite.com) and when users
    > type
    > www.ourwebsite.com/jack or www.ourwebsite.com/sue, I can figure out the[/color]
    name[color=blue]
    > (jack or sue) and get the id of the user from database and bring the[/color]
    content[color=blue]
    > of that user's web pages from database.
    >
    > I put the following code into Application_Beg inRequest event in[/color]
    Global.asax[color=blue]
    > file:
    >
    > dim sFolderName As String = Request.Applica tionPath.ToStri ng.Trim("/")
    > dim AgentID as long = GetAgentIdByFol derName(sFolder Name) 'from the
    > database
    > WriteAgentIdToC ookie(AgentID)
    > Server.Transfer ("AgentHomePage .aspx")
    >
    > After writing the agent Id to client's cookie, I redirect to agent home[/color]
    page[color=blue]
    > and at this page, I read cookie and get agent id and bring the agent info
    > like its picture URL and home page info from database.
    >
    > The problem is: When I type : www.oursite.com/Jack
    > I faced this error: page can not be found!
    >
    > Do you think global.asax is a good place to put this code? and also this
    > code: Request.Applica tionPath ? HttpRequest or something?
    > Is there a better way to get what user typed I mean the folder name that
    > comes after my website.
    >
    > I got web hosting service from another company so I do not have any[/color]
    control[color=blue]
    > over that company's IIS. I could not found a way in its web hosting's[/color]
    admin[color=blue]
    > site to set the default page. Any page with default or index name will[/color]
    come[color=blue]
    > when I type www.oursite.com without including file name.
    >
    > Please help. Thank you very much in advance
    >
    > Best Regards
    > Andy Eshtry
    >
    >
    >
    >[/color]


    Comment

    • Amir Eshterayeh

      #3
      Re: simulate virtual directory for each user

      Dear Mr. Scott and other friends
      The point is my company sell the virtual directorys and give users
      specific URL I mean www.mycom.com/sue or www.mycom.com/sandy
      so that she can print the website with her name on her business card.
      What are the ways I can show each user, typing the url I mention, his/her
      specific content?
      Thanks for your kind attention
      Andy Eshtry

      "Scott M." <s-mar@BADSPAMsnet .net> wrote in message
      news:%23kX3BLg6 DHA.1072@TK2MSF TNGP11.phx.gbl. ..[color=blue]
      > Could you be more specific as to why each user needs their own directory?
      > What would "Jack" get that requires him to have a different directory than
      > "Sue" or "Tom"?
      >
      > I ask because ASP.NET can build content on the fly. Content can be cached
      > based on an url parameter (i.e. the user) so that different users get
      > different output. And, there are many more options to ensure that[/color]
      different[color=blue]
      > users to a site get different results.
      >
      >
      > "Amir Eshterayeh" <aeshterayeh@ho tmail.com> wrote in message
      > news:%23ypqklf6 DHA.2656@TK2MSF TNGP11.phx.gbl. ..[color=green]
      > > Dear Friends
      > >
      > > Would you please give me your professional idea about this asp.net[/color]
      > problem.[color=green]
      > >
      > > I need different virtual directory for different customer with their[/color][/color]
      names[color=blue][color=green]
      > > like these:
      > > www.oursite.com/Jack
      > > www.oursite.com/Sue
      > > www.oursite.com/Tom
      > >
      > > I have a asp.net project. It is a website and the content of it WebPages
      > > comes from database.
      > > To give each user a virtual directory, I have 2 options:
      > > 1. create a virtual directory for each user and copy the asp.net project[/color]
      > to[color=green]
      > > each directory
      > > This is not a good solution.
      > > 2. Copy all the files to root directory (www.oursite.com) and when users
      > > type
      > > www.ourwebsite.com/jack or www.ourwebsite.com/sue, I can figure out the[/color]
      > name[color=green]
      > > (jack or sue) and get the id of the user from database and bring the[/color]
      > content[color=green]
      > > of that user's web pages from database.
      > >
      > > I put the following code into Application_Beg inRequest event in[/color]
      > Global.asax[color=green]
      > > file:
      > >
      > > dim sFolderName As String = Request.Applica tionPath.ToStri ng.Trim("/")
      > > dim AgentID as long = GetAgentIdByFol derName(sFolder Name) 'from the
      > > database
      > > WriteAgentIdToC ookie(AgentID)
      > > Server.Transfer ("AgentHomePage .aspx")
      > >
      > > After writing the agent Id to client's cookie, I redirect to agent home[/color]
      > page[color=green]
      > > and at this page, I read cookie and get agent id and bring the agent[/color][/color]
      info[color=blue][color=green]
      > > like its picture URL and home page info from database.
      > >
      > > The problem is: When I type : www.oursite.com/Jack
      > > I faced this error: page can not be found!
      > >
      > > Do you think global.asax is a good place to put this code? and also this
      > > code: Request.Applica tionPath ? HttpRequest or something?
      > > Is there a better way to get what user typed I mean the folder name that
      > > comes after my website.
      > >
      > > I got web hosting service from another company so I do not have any[/color]
      > control[color=green]
      > > over that company's IIS. I could not found a way in its web hosting's[/color]
      > admin[color=green]
      > > site to set the default page. Any page with default or index name will[/color]
      > come[color=green]
      > > when I type www.oursite.com without including file name.
      > >
      > > Please help. Thank you very much in advance
      > >
      > > Best Regards
      > > Andy Eshtry
      > >
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Scott Allen

        #4
        Re: simulate virtual directory for each user

        One way to achieve this functionality is to do URL rewriting.

        In ASP.NET you write a class to implement the IHttpModule interface.
        Attach an event handler to the HttpApplication object's BeginRequest
        event. Inside the event handler you can determine who the user is, set
        variables in the Context object to remember them (you can pull them
        out during page processing), then do a Content.Rewrite Path to assign
        an internal path to the resource. So the user may see
        www.mycom.com/sue/default.aspx but this page doesn't actually exist.
        You may internally be sending the runtime to process the request from
        x:\wwwroot\user default.aspx.

        You configure the new module into your application through an entry in
        the <httpModules> section of web.config.

        This technique is popular in a number of open source projects you can
        look at (the Community Starter Kit at http://asp.net and .Text blog
        engine). I'm sure with some searching you can find other references.

        --
        Scott


        On Tue, 3 Feb 2004 11:26:52 -0800, "Amir Eshterayeh"
        <aeshterayeh@ho tmail.com> wrote:
        [color=blue]
        >Dear Mr. Scott and other friends
        > The point is my company sell the virtual directorys and give users
        >specific URL I mean www.mycom.com/sue or www.mycom.com/sandy
        >so that she can print the website with her name on her business card.
        >What are the ways I can show each user, typing the url I mention, his/her
        >specific content?
        >Thanks for your kind attention
        >Andy Eshtry
        >
        >"Scott M." <s-mar@BADSPAMsnet .net> wrote in message
        >news:%23kX3BLg 6DHA.1072@TK2MS FTNGP11.phx.gbl ...[color=green]
        >> Could you be more specific as to why each user needs their own directory?
        >> What would "Jack" get that requires him to have a different directory than
        >> "Sue" or "Tom"?
        >>
        >> I ask because ASP.NET can build content on the fly. Content can be cached
        >> based on an url parameter (i.e. the user) so that different users get
        >> different output. And, there are many more options to ensure that[/color]
        >different[color=green]
        >> users to a site get different results.
        >>
        >>
        >> "Amir Eshterayeh" <aeshterayeh@ho tmail.com> wrote in message
        >> news:%23ypqklf6 DHA.2656@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
        >> > Dear Friends
        >> >
        >> > Would you please give me your professional idea about this asp.net[/color]
        >> problem.[color=darkred]
        >> >
        >> > I need different virtual directory for different customer with their[/color][/color]
        >names[color=green][color=darkred]
        >> > like these:
        >> > www.oursite.com/Jack
        >> > www.oursite.com/Sue
        >> > www.oursite.com/Tom
        >> >
        >> > I have a asp.net project. It is a website and the content of it WebPages
        >> > comes from database.
        >> > To give each user a virtual directory, I have 2 options:
        >> > 1. create a virtual directory for each user and copy the asp.net project[/color]
        >> to[color=darkred]
        >> > each directory
        >> > This is not a good solution.
        >> > 2. Copy all the files to root directory (www.oursite.com) and when users
        >> > type
        >> > www.ourwebsite.com/jack or www.ourwebsite.com/sue, I can figure out the[/color]
        >> name[color=darkred]
        >> > (jack or sue) and get the id of the user from database and bring the[/color]
        >> content[color=darkred]
        >> > of that user's web pages from database.
        >> >
        >> > I put the following code into Application_Beg inRequest event in[/color]
        >> Global.asax[color=darkred]
        >> > file:
        >> >
        >> > dim sFolderName As String = Request.Applica tionPath.ToStri ng.Trim("/")
        >> > dim AgentID as long = GetAgentIdByFol derName(sFolder Name) 'from the
        >> > database
        >> > WriteAgentIdToC ookie(AgentID)
        >> > Server.Transfer ("AgentHomePage .aspx")
        >> >
        >> > After writing the agent Id to client's cookie, I redirect to agent home[/color]
        >> page[color=darkred]
        >> > and at this page, I read cookie and get agent id and bring the agent[/color][/color]
        >info[color=green][color=darkred]
        >> > like its picture URL and home page info from database.
        >> >
        >> > The problem is: When I type : www.oursite.com/Jack
        >> > I faced this error: page can not be found!
        >> >
        >> > Do you think global.asax is a good place to put this code? and also this
        >> > code: Request.Applica tionPath ? HttpRequest or something?
        >> > Is there a better way to get what user typed I mean the folder name that
        >> > comes after my website.
        >> >
        >> > I got web hosting service from another company so I do not have any[/color]
        >> control[color=darkred]
        >> > over that company's IIS. I could not found a way in its web hosting's[/color]
        >> admin[color=darkred]
        >> > site to set the default page. Any page with default or index name will[/color]
        >> come[color=darkred]
        >> > when I type www.oursite.com without including file name.
        >> >
        >> > Please help. Thank you very much in advance
        >> >
        >> > Best Regards
        >> > Andy Eshtry
        >> >
        >> >
        >> >
        >> >[/color]
        >>
        >>[/color]
        >[/color]

        Comment

        Working...