locked
How does page redirection work in ASP.NET? RRS feed

  • Question

  • This question has not been asked here.  This is not the same as launching a new browser tab.  This is a complete redirection.  How is this done?  What is more, it is a redirection to a child process at runtime.

    I have asked this question and described this scenario on another web forum.  So do not sue me for asking this question twice.  It is good to get multiple opinions.

    I have inherited an ASP.NET project and I have lots of questions.

    Here is the first question.  How does page redirection work in ASP.NET?  The solution file seems to contain a number of child projects.  The parent project, when loaded into visual studio, contains child projects:

    This parrent solution / project is an application type.  So it has a .cproj and a .sln file in the "Applications" directory.

    http://i67.photobucket.com/albums/h292/Athono/webproject_zps964ca8c2.png

    Here is the first mystery.  When all this is put on the web server, and after the user goes to the location where the "Applicationis" directory is, he is automatically directed to the "Graduate" folder and the Default.aspx file there.  THe 'Graduate" child project is not a project but a "Web Site"

    http://i67.photobucket.com/albums/h292/Athono/website_zps01f24257.png

    So my first question is this.  How is this done?

    Also, how can I open the parent project and set the child project as the main focus?  Here is one reason why this is important to understand.  The parent project has a problem with its web.config file when I try to debug from this level.  On the other hand, when I open the "Graduate" web site child project, warnings are thrown because the compiler cannot find shema information for tags used in the web.config on that level.  So, so far, nothing can be debugged.    

    Please advise.

    Wednesday, February 13, 2013 1:14 AM

Answers

  • The key word is project.  A project has a .csproj file, the project is the .csproj file.  A solution has a .sln file, a solution is a .sln file. If you open the .csproj file in notepad you will see the definition of the project, all the settings and all the files that make it up.  Similarly, if you open the .sln file you will see all the solution settings and all the projects that make up the solution.

    A web site is a much more ill defined thing.  In fact, if you go to File->open->web site.. in Visual studio all you get is a folder browser.  I have just done that and opened 'My Pictures' as a web site.  All it contains is pictures, it is not a web site.  Being able to use VS to 'Open a Web Site' proves that the thing you opened is a folder, no more and no less.

    Note the icon next to Applications in solution explorer.  That tells you it is a project.  See the icon next to Graduate?  That tells you it is a folder.

    Showing the Right Click menu which allows you to open a web site says nothing whatsoever about the current object.  It neither says nor implies that the thing you have right clicked is a web site nor that it is not a web site.

    How has your web server been setup?  It is the server which determines which page is returned when the request does not specify a page.  If you are using the development server built in to Visual Studio (Cassini, I believe, is the name the cool kids use for it) then you sepcify what url to visit as a property of the project.  Right click on the only project that you have and choose Properties.  Click on the web tab.  What is selected for 'Start Action'?

    What is in global.asax?  Code in there is capable of redirecting a request for a url to a different piece of code/page/url.

    Is there any url rewriting going on in web.config?  That can also make a different page be selected.

    (I don't know if you are aware but your responses to people who are trying to help you come across as quite agressive.  I'm sure you don't mean it that way but it is quite off putting and may discourage some people who don't have a thick skin)


    Paul Linton

    • Proposed as answer by Bob Shen Friday, February 22, 2013 7:12 AM
    • Marked as answer by Bob Shen Tuesday, February 26, 2013 2:43 AM
    Tuesday, February 19, 2013 3:29 AM

All replies

  • better you just do google 

    thanks and regard love4csharp

    Wednesday, February 13, 2013 6:27 AM
  • At the top of the solution explorer it says

    Solution 'Applications' (1 project)

    That means that you have a solution with a single project.  In your case that single project has the same name as the solution and this is quite common.  The sub-options on the Open menu command do not tell you what type of object you currently have, they just tell you what kinds of thing you can open.

    So, 'Graduate' is not a web site project, it is a folder in the 'Applications' project.

    Which page is opened when you visit a web site without specifying a particular page is controlled by the web server (I only know the case of IIS but I imagine that others are the same).  So, if someone browses to www.mySite.com then the server for mySite will have been set with a default page and that is the one that the user will see.

    So, what is the default for your web site?  Once you know that you can have a look at that page in your project and see what it does.


    Paul Linton

    Wednesday, February 13, 2013 7:28 AM
  • Hi,

    By default when you type www.mysite.com you goes to www.mysite.com/default.aspx See what contains this page (it could contains a response telling to the browser it should go to www.mysite.com/somefolder/default.aspx.

    It could also have been done using other methods (to really find out what happens you could use the developer tool in IE9 or FireFox to see what is exchanged between the server and client side).


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Wednesday, February 13, 2013 9:31 AM
  • Hi,

    By default when you type www.mysite.com you goes to www.mysite.com/default.aspx See what contains this page (it could contains a response telling to the browser it should go to www.mysite.com/somefolder/default.aspx.

    It could also have been done using other methods (to really find out what happens you could use the developer tool in IE9 or FireFox to see what is exchanged between the server and client side).


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    This is part of the mystery.  There is no default.aspx on the "parent" level.  The parent project is not a "Web Site" type of app.

    Instead, it is a web app.  There is no Default.aspx.  Pictured below are the files that are on the parent level.  Tell me, which one does the page redirection?

    Tuesday, February 19, 2013 1:54 AM
  • At the top of the solution explorer it says

    Solution 'Applications' (1 project)

    That means that you have a solution with a single project.  In your case that single project has the same name as the solution and this is quite common.  The sub-options on the Open menu command do not tell you what type of object you currently have, they just tell you what kinds of thing you can open.

    So, 'Graduate' is not a web site project, it is a folder in the 'Applications' project.

    Which page is opened when you visit a web site without specifying a particular page is controlled by the web server (I only know the case of IIS but I imagine that others are the same).  So, if someone browses to www.mySite.com then the server for mySite will have been set with a default page and that is the one that the user will see.

    So, what is the default for your web site?  Once you know that you can have a look at that page in your project and see what it does.


    Paul Linton

    You said "So, 'Graduate' is not a web site project, it is a folder in the 'Applications' project."  This is not so.  I can close this project.  Then I can use the Visual Studio to navagate to the Graduate folder, then open this one as a seperate Web Site project.
    Tuesday, February 19, 2013 1:56 AM
  • The key word is project.  A project has a .csproj file, the project is the .csproj file.  A solution has a .sln file, a solution is a .sln file. If you open the .csproj file in notepad you will see the definition of the project, all the settings and all the files that make it up.  Similarly, if you open the .sln file you will see all the solution settings and all the projects that make up the solution.

    A web site is a much more ill defined thing.  In fact, if you go to File->open->web site.. in Visual studio all you get is a folder browser.  I have just done that and opened 'My Pictures' as a web site.  All it contains is pictures, it is not a web site.  Being able to use VS to 'Open a Web Site' proves that the thing you opened is a folder, no more and no less.

    Note the icon next to Applications in solution explorer.  That tells you it is a project.  See the icon next to Graduate?  That tells you it is a folder.

    Showing the Right Click menu which allows you to open a web site says nothing whatsoever about the current object.  It neither says nor implies that the thing you have right clicked is a web site nor that it is not a web site.

    How has your web server been setup?  It is the server which determines which page is returned when the request does not specify a page.  If you are using the development server built in to Visual Studio (Cassini, I believe, is the name the cool kids use for it) then you sepcify what url to visit as a property of the project.  Right click on the only project that you have and choose Properties.  Click on the web tab.  What is selected for 'Start Action'?

    What is in global.asax?  Code in there is capable of redirecting a request for a url to a different piece of code/page/url.

    Is there any url rewriting going on in web.config?  That can also make a different page be selected.

    (I don't know if you are aware but your responses to people who are trying to help you come across as quite agressive.  I'm sure you don't mean it that way but it is quite off putting and may discourage some people who don't have a thick skin)


    Paul Linton

    • Proposed as answer by Bob Shen Friday, February 22, 2013 7:12 AM
    • Marked as answer by Bob Shen Tuesday, February 26, 2013 2:43 AM
    Tuesday, February 19, 2013 3:29 AM