[RESOLVED] Question about localhost:nnnn vs localhost
If I hit F5 in Visual Studio, my web app is running from localhost:nnnn. None of my images or styling is available. If I modify the URL in the browser and delete the :nnnn so it's just localhost, the page is styled and all images resolve.
Any idea why this is happening and how I can prevent it; that is, make it run from localhost to begin with?
Thanks.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
You can set the port that cassini will use from the Web tab in the project properties. The question is how are you setting the paths to your css and image files if they break when a port number is added?
This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.
The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.
1. Are you running this through local IIS or with the VS web server? Local IIS.
2. odds are the pathings are full... rather than relative... Are you saying make them relative? I shouldn't have to modify any existing code because it is working; that is, it's a live site and all I did was get the project from another developer. I don't want to change anything just to make it work on my machine.
3. You can set the port that cassini will use from the Web tab in the project properties. What is cassini?
Thanks for the answers. I will look into this further.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
1. Are you running this through local IIS or with the VS web server? Local IIS.
2. odds are the pathings are full... rather than relative... Are you saying make them relative? I shouldn't have to modify any existing code because it is working; that is, it's a live site and all I did was get the project from another developer. I don't want to change anything just to make it work on my machine.
3. You can set the port that cassini will use from the Web tab in the project properties. What is cassini?
Thanks for the answers. I will look into this further.
Cassini is what Visual Studio is using to run your web application, rather than IIS itself. Typically when I am building web applications, I set the project to use local IIS rather than Casini, so that it avoids just this kind of confusion.
You can set your project to use IIS rather than Casini by going into project properties, clicking the "web" tab and setting the project to use local IIS.
Ah, so that popup that says ASP.NET Development Server - that is Cassini. Good to know (better late than never, right?)
At this risk of sounding (even more) like an idiot, I can't find what you (and the rest of the world) are telling me to do...
You can configure a web project within Visual Studio to use IIS by right-clicking on the project and pulling up its properties (and then by clicking on the “Web” tab within the properties window)":
Which properties - property pages or properties window? Neither one of these is giving me a Web tab.
Last edited by MMock; May 2nd, 2013 at 07:13 AM.
Reason: typo
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
And if I wanted to still use Cassini (I don't think I've ever not used it - didn't know you had a choice or what pros/cons were) I can't change the port number?
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Someone posted this: When I look at Properties for the project, I just see two properties: Full Path and Opened URL. When I look at the Property Pages, I see 6 sections: References, Build, Accessibility, Start OPtions, MSBuild Options, and Silverlight Applications. THe Start Options has a "server" section that only has two options: Use default Web server, and Use custom server. Nothing about Use Visual Studio Development Server. There is no "Web" section.here, so I am reading that thread as that is exactly what I see for properties.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Lots of talk here - but back to an initial question / observation...
What are the paths - full or relative?
And a followup question - do you really care if the images do not appear while you are working the page? In otherwords - are you adding an enhancement and then simply shipping your changes back to the production user?? You could possibly - for the time you are working the app - create an image folder "where the page is looking for it" locally...
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Sorry, I thought this was common terminology. I didn't mean to muddy the issue with it.
I've attached a couple of screen shots to get you in the right place. If you're using VB.NET you'll double click on My Project to get to the properties while it'll just say Properties in a C# project. From there you can click on the Web tab on the left hand side to get to the server section in the other screenshot.
You'll see that if you use IIS Express you can override the root URL.
This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.
The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.
Yes, I could totally ignore this issue. The images are resolved if I simply override, once the browser is up, the URL and remove nnnn from localhost:nnnn. But, I am bored and was told to "familiarize" myself with the code, so I figured why not delve into this issue and understand it? But, you are totally right and I was just given something else to do so I will switch out of this for the time being. Thanks Steve.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Thanks MattP. I will look at that when I get a break from a report I have to modify. And muddy? Hell, no. I learned something which I always took for granted - I thought it was always using the ASP.NET Development Server and never even noticed when it wasn't (by "it", I mean everything I ever ran!)
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Here's a screen shot from VS 2008 - working on a web app that is not "setup as a project" (I believe).
I got to properities that seem to look like the screen shot from VS 2010 by right-clicking the "D:\ACS DESKTOP\AWC" spot and going into properties...
At any rate - when you start the DEBUGGER running with F5 you are setting up communications through a particular PORT...
Why do you feel comfortable removing that "port designation" from the URL? Doesn't that stop the page from working further (or is this some static type of page without much back and forth?)
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Why do you feel comfortable removing that "port designation" from the URL? Doesn't that stop the page from working further (or is this some static type of page without much back and forth?)
No, there's plenty of back and forth, or at least forth. I'm comfortable with it because it works. Is that because it navigates using Server.Transfer so once I've changed the port it keeps that change? (Or is that a stupid question?)
I'll look at your screen shot when I have a couple minutes.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
I also do not know - I'm curious to hear from someone else how removing the port from the URL is doing anything to fix this situation...
I don't see how it could help.
In one instance, the web site of being rendered by ASP.Net Development Server (Cassini), using the allocated Port Number. When you strip off the Port Number you are rendering the page from the site hosted under the local IIS. Although both of these things might be looking at the same files, they are ultimately coming from different servers.
I suspect that if we find out what is in the variable that I just asked about, we will find out where the problem lies.
Yes, any session state would be lost, as they are coming from two different places, unless of course any session state was being persisted elsewhere, i.e. SQL Server.
Yes, I would agree with that, removing the port number is NOT a solution.
This code - which I do in one of my web methods - for example - would not work (as the Application object is persisted by the web service executable - I've stopped the ASP.NET DEVELOPMENT SERVER to reset this collection)
Code:
Private Sub DetermineParameters(ByRef dcn As SqlConnection, ByRef cmd As SqlCommand, Optional ByRef errorText As String = "")
Dim blnError As Boolean = False
Dim blnDoClose As Boolean = False
With Application
.Lock()
If .Item("g_prmSP") IsNot Nothing Then
g_prmSP = DirectCast(.Item("g_prmSP"), Dictionary(Of String, SqlParameter()))
End If
.UnLock()
End With
.
.
.
With Application
.Lock()
.Item("g_prmSP") = g_prmSP
.UnLock()
End With
End Sub
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
then Mock should edit some of the posts here where she removed the port # and INDICATE that it's not a PROPER SOLUTION...
I didn't see any post of mine where I said that. I didn't say "I'm not getting images" and then "oh, I fixed that by removing the port #'. I posted to understand what's going on, and I am describing what I observe. Can you direct me to which post you felt I had indicated some solution to this?
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Post #15 - this reply here and the fact that removing the port was part of the first post here made me concerned that if this thread was quickly read someone might think it was ok to alter the URL that the IDE decided to launch a debug session with.
Of course - that's not the case - as the SERVICE EXECUTABLE is only listening on that PORT. Removing the PORT is like removing your leg and putting on wheels - gonna get unexpected results.
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Well, the removal of the port was actually the issue - not the solution. If I'd thought it was a solution, I never would've posted in the first place because I knew right away that with no port number my images resolved. But I wanted to know why.
And the only reason I even thought to try removing the port and see what happened was because my coworker sent me a screen shot of the app running locally on her PC, and I noticed the difference in our URL's.
If this thread is too confusing and is going to steer someone astray, by all means delete it.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
No - not at all - good conversation going on here - and I would like to know how the image paths are being handled differently by the two different ASP.Net host apps.
If you can re-direct your IDE to use the NON-CASSINI SERVICE - and the IMAGE work - then you have a solution that is viable and reasonable.
Leaving open the question as to why the "ASP.NET DEVELOPMENT SERVER" is doing it different.
Do the images work if the IDE launches to a different service you have on your machine?
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Do the images work if the IDE launches to a different service you have on your machine?
I'm sorry, I don't quite know what that means, "launch to a different service"...
I may ask stupid questions back to your intelligent questions - I don't know anything about this app yet. I just installed the project for future maintenance when it was turned over from another department to ours.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
(I renamed to "theURL" here from our company acronym XXX). So these are three (broken) links at the top of the page to go to Home, Careers and Site Requirments.
If I hover over these links, I get localhost, localhost, localhost:1609 respectively.
If I View Source, I get
Code:
<div id="searchTopNav">
<a href="http://localhost/XXX web enrollment/default.aspx">Home</a> <img src='/Images/bullet-nd.gif' border='0'>
<a href="http://localhost/XXX web enrollment/careers.aspx">Careers</a> <img src='/Images/bullet-nd.gif' border='0'>
<a href="/GlobalFiles/SiteRequirements.asp">Site Requirements</a>
Does that lend any understanding to what's going on?
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Maybe I should also add...if I next edit the URL displayed in the browser and remove 1609, the links resolve and the styling kicks in, I hover over the three links and they are localhost/localhost/localhost, I view source and I get:
Code:
<div id="searchTopNav">
<a href="http://localhost/XXX web enrollment/default.aspx">Home</a> <img src='/Images/bullet-nd.gif' border='0'>
<a href="http://localhost/XXX web enrollment/careers.aspx">Careers</a> <img src='/Images/bullet-nd.gif' border='0'>
<a href="/GlobalFiles/SiteRequirements.asp">Site Requirements</a>
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
I should never have said the links resolve. It is the images that resolve. In other words, see how it is using bullet-nd.gif? That image is just a tiny red square used as a separator. So it goes Home ~ Careers ~ Site Requirements and the tilde is this image. I described this correctly in post #1. When the port is 1609, I don't have the red square, I have an X.
On the other hand, the links do not work either way. Home wants to go to default.aspx and if I click it I get The resource cannot be found. Same thing with the Careers link trying to go to careers.aspx. And Site Requirements, because it's asp, gives me a 404.
You asked if these pages are in the same folder. So no, it appears I do not even have them.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
First - let's make things clear - the port has nothing to do with your issue. When you see the PORT on the URL that means you are getting pages served to you by the default iis service for the IDE.
You need to get the IDE to know where these files are.
Removing the PORT is disconnecting you from the IDE - from the debugger. All the port is is a listening channel for the "service". No port simply DEFAULTS to PORT 80!!!
So - back to the problem - what do you mean by
So no, it appears I do not even have them.
Are you saying you do not have a folder with these files in it?
Can you take a screen shot of the SOLUTION EXPLORER so we can see the folder and files you are dealing with?
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Removing the PORT is disconnecting you from the IDE - from the debugger
Oh, I see that now that you've pointed it out...
Originally Posted by szlamany
Are you saying you do not have a folder with these files in it?
Can you take a screen shot of the SOLUTION EXPLORER so we can see the folder and files you are dealing with
No, I'm sorry - this company is very secure and I am a contractor not an employee so I'd rather err on the side of caution. I know that makes it difficult to get help. I will say that nowhere in the solution do I have a Careers.aspx file
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
you can only use 1609 if that's the port that VS started the ASP.Net dev environment under - do you know how to see the port being currently used? It's in the HIDDEN ICONS taskbar thingy for me on my Windows 7 machine...
At any rate - - poke around and create an IMAGES folder up or down from the folder it's looking for and see if you can at least get the image to be found.
Also - if you use FIREBUG you can see the actual path being attempted by the tcpip call.
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".