2

I'm reading Pro Asp.net 4.5 using C# by Adam Freeman I'm stuck where he is adding routes to RouteConfig.cs class in App_Start folder.

When I change

project properties -> Web Tab ->
 Specific Page (Inside Start Action section) -> Specify "list"

and try to test it, it shows directory not found error.

Any of following combinations :

list/2
list/3...

doesn't work

IISExpress/appconfiguration code :

<!-- language: xml -->

    <site name="SportsStoreApplications" id="23"> 
        <application path="/" applicationPool="Clr4IntegratedAppPool"> 
            <virtualDirectory 
                path="/" 
                physicalPath="c:\users\krushank\documents\visual studio 2012\Projects\SportsStoreApplications\SportsStoreApplications" /> 
        </application> 
        <bindings> 
            <binding protocol="http" bindingInformation="*:3079:localhost" /> 
        </bindings> 
    </site>

In short I am trying to route to a specific url "list"

RouteConfig.cs class with routes defined

Link to download the zip : https://www.dropbox.com/s/xsuzd1hua3pdvsq/SportsStoreApplications.zip?dl=0

thor
  • 21,418
  • 31
  • 87
  • 173
  • 1
    Hi, Welcome to Stack Overflow. It would be better to include code and any exceptions directly in your question. Also (and don't take this as being mean), I'm not going to look up a book and find the chapter you are stuck on. Try to include a full working *minimal* example of the code you are working with, if possible. See: http://stackoverflow.com/help/how-to-ask for a lot of good information on asking questions here. – gmiley May 12 '16 at 23:47
  • you seem to be studying asp.net MVC, not ASP .net. Mentioning simply ASP.net generally gives an impression of ASP.Net web form. Please correct me if I'm wrong. – RBT May 13 '16 at 00:15
  • In `project properties -> Web -> Specific -> list/(manually doing 2...3)` what is this specific thing. I don't see any section named specific on web tab in project properties. – RBT May 13 '16 at 00:28
  • @RBT Specify is after current page tab in Web – user3786445 May 13 '16 at 00:47
  • @gmiley Please click image link that includes the code. It is Asp.net not Mvc – user3786445 May 13 '16 at 00:57
  • ohh you mean `specific page` option under `Start Action` section on web tab in project properties. Did you? – RBT May 13 '16 at 01:24
  • @RBT yes exactly where I type "list" as per my routeconfig.cs file which is in code snippets images – user3786445 May 13 '16 at 01:26
  • Are you using IIS or IIS Express? If IIS Express, could you include the `` block for your site definition in your applicationhost.config file and maybe include a screen capture of your solutions `Web` tab containing the relevant information? Also, if you just put a static html test page in that directory, can you browse to it and view it? – gmiley May 13 '16 at 01:33
  • @gmiley can you share a snippet or example where I should put it as I am using iis express – user3786445 May 13 '16 at 01:38
  • I want to see what you have in your applicationhost.config file for the ... block. It is likely located in your `My Documents/IIS Express/config/` folder. There should be a section ` /* your site configuration elements */ ` in that config file. After reviewing the configuration you have, you should ensure that where it is configured to point does indeed exist and contains the document(s) you are trying to access. Just modify your question to include the xml block so we can take a look at that. – gmiley May 13 '16 at 01:41
  • Also, what exactly do you have typed into your "Specify URL" field? Are you typing in the full url? `http://localhost/list/1` ? And, like I mentioned, can you put a static `test.html` document in your site folder and access it? `http://localhost/test.html`? And can you type in, and access: `http://localhost/Pages/Listing.aspx`? – gmiley May 13 '16 at 01:51
  • Your source code is working perfectly fine on my machine. Can you please double check that you have a directory named `Pages` in your project solution structure and `listing.aspx` page is actually present inside `Pages` directory only. There should be no typo mistakes in directory name or web form page name. – RBT May 13 '16 at 01:56
  • @gmiley heres my app_code – user3786445 May 13 '16 at 02:15
  • Edit your question to include it there, not in the comments. However, in the meantime - can you confirm as @RBT and myself asked, does the `Pages` directory exist, and can you access the `Listings.aspx` page directly? With the information you provided, when you run your applications and browse directly to `http://localhsot:3079/Pages/Listings.aspx` does it get to your page properly? – gmiley May 13 '16 at 02:19
  • @gmiley everything works except when i type "list" as in my routeconfig class – user3786445 May 13 '16 at 02:19
  • Do you have the URL specified as: `http://localhsot:3079/list/1` ? – gmiley May 13 '16 at 02:20
  • @gmiley yes exactly, but it shows 404 directory not found error – user3786445 May 13 '16 at 02:22
  • @gmliey Pages directory has Listing.aspx as specified - Checked – user3786445 May 13 '16 at 02:27
  • Add a `Debug.WriteLine("Routes added...");` or code to loop through the collection and write out all the routes to the output window, to your `RegisterRoutes()` method, and check your output window to ensure it is running and adding the routes. – gmiley May 13 '16 at 02:28
  • @gmiley its not adding to console anything... – user3786445 May 13 '16 at 02:32
  • Then your site is not being executed correctly.. In your `Web` tab of the solution properties, ensure that the IIS Express section is set up properly. can you take a screen capture of that whole tab and include it in your question? Do you have multiple copies of this solution that you might be running a different version of? Also, maybe try cleaning the solution, not just the menu `Clean Solution`, but go into the solution folder and in each project folder delete both the `bin` and `obj` directories and rebuild and run the solution. – gmiley May 13 '16 at 02:44
  • @gmiley added the pic of Web tab in question for your reference – user3786445 May 13 '16 at 02:51
  • @gmiley still doesnt work – user3786445 May 13 '16 at 02:56
  • Change `Specific Page:` from "list" to use `Specific URL` with the value `http://localhsot:3079/list/1` and click the `Create Virtual Directory` button in the IIS Express section. If that still doesn't work, open up your `applicationhost.config` file and delete all of your `` blocks inside of the `` block. Save it, then repeat the step above of clicking the `Create Virtual Directory`, then you should only have 1 `` block entry in your applicationhsot.confic. I am still wondering why you aren't seeing any debug output. Are you running the site in Debug mode or Release? – gmiley May 13 '16 at 02:56
  • @gmiley Debug mode – user3786445 May 13 '16 at 02:58
  • @gmiley nothing worked that way either - is it possible for you to execute my project if i send you as a zip...its a basic file as i am learning – user3786445 May 13 '16 at 03:05
  • I guess you can put it up somewhere as an archived zip or rar. I can take a quick look at it. That may end up being a lot easier to see the entire thing. – gmiley May 13 '16 at 03:08
  • @gmiley here is the link to download it : https://www.dropbox.com/s/xsuzd1hua3pdvsq/SportsStoreApplications.zip?dl=0 – user3786445 May 13 '16 at 03:17
  • @gmiley I really appreciate you taking a moment to look at it...god bless ...learnt lot with you though – user3786445 May 13 '16 at 03:20
  • @gmiley did you by any chance saw my code ?? I am eagerly awaiting your reply...thanks – user3786445 May 13 '16 at 13:13
  • I looked at it some last night, but it was late by the time I got into it so I didn't really get a good chance to look it all over. I am at work right now and cannot access it from here. It will have to wait until later this evening. Sorry. – gmiley May 13 '16 at 14:57
  • @gmiley I appreciate and I will wait – user3786445 May 13 '16 at 14:58
  • @gmiley I started making it again from scratch and i succeded. It was a real horror .... feels awesome now! Thanks for all your help. – user3786445 May 13 '16 at 17:15

1 Answers1

0

I started making it again from scratch and i succeded. It was a real horror since yesterday.... feels awesome now! Thanks for all your help

I recycled IIS Expresss...whole application ...nothing worked else than making it from scratch...

thanks @RBT and @gmiley for all your help

  • Glad that you are out of your problem. atleast you learned how useful this website is and basic guidelines of writing Q & A. Keep helping people and keep getting help from people. Technological fraternity wins at the end of the day! – RBT May 13 '16 at 23:13
  • Glad you got it working. I ended up going through your copy of the solution and one I made from scratch. For some reason I could not get your global.asax to load anything. which was very strange. Mine worked perfectly. I am betting you just got a corrupt solution or project file somewhere along the way. That seems like a pretty crappy explanation, but honestly, I have no answer. =) – gmiley May 13 '16 at 23:28