Publishing Website Errors

ivonsurf123

New member
Joined
Sep 13, 2024
Messages
4
Programming Experience
Beginner
Hello,

I just have a question that I cannot find in Google, but I have this website that brings photos through a path that I have built in the code like this:

CODE:

// Base path configurable
string baseImagePath = ConfigurationManager.AppSettings["ImageBasePath"] ?? @"\\WCUPOBPROC1-A\Old_Check_Images";

When I run it in my local computer, it works perfectly and the path that shows in the web browser is this:

https://localhost:44339/Images.aspx

But now that I have published in the server to go Live as a website, It is not working and the path in the browser is:

https://fnweb.wescom.org/Old_Check_Images/Images.aspx

But It gave me a few errors:

Error 404:

Error occurred on recovery Image: Error 404:

no-image.png:1

GET https://fnweb.wescom.org/Old_Check_Images/no-image.png 404 (Not Found)

Any help to resolve this issue will be appreciate it. Thank you.
 
Moving to ASP.NET...

You need to understand the code that you have written. If you didn't write the code, you need to ask the person from whom you took the code from. Your code has a null value handler that lets it fall back to a different value if the setting is null.

Either you have the hosting site a bad web.config file, or the hosting site modified the web.config to something different from what your have them. I either case, IIS could not find the "ImageBasePath" in the <appSettings> section of the web.config file, and so your code is falling back to your null handler.
 
*sigh* It would be helpful if you provided here the details that you provided in your Reddit cross-post of this same question.

Of note from your Reddit post:
All the photos are in this path: \\WCUPOBPROC1-A\Old_Check_Images

What I do is create the path and when insert the specific variables start building the path and after building the correct path, then start the searching. It does work perfectly in my local, but when i publish it to this site;

If the code is running on the web server that presumably is hosted on another machine, does that machine have access to the machine "WCUPOBPROC1-A" ? Does the app pool identity hosting your app have permissions to the file share: "\\WCUPOBPROC1-A\Old_Check_Images"?

You also mentioned that you are doing some path processing. It would help if you add some logging so that you can figure out what the initial baseImagePath value is, and the new values as you do that processing to end up with your resultant path. That will give you the most information about what is going on. You will be able to look at the logs to see what reality is as compared to your expected values. That's how debugging works -- tracing code paths and variable values. Debugging is not "run it and see if it looks right".
 
Is this the reason you open or join this forum? To mocked beginners and juniors developers? All that you have done in your two comments were just insulting and questioning me if that is my code or not but just providing helpful insights to start searching or investigating. I exhaust all the ways that I can think of before I post anything on any forum. I may not be perfect and know it all as you do apparently, but I try to built something every month through Udemy classes and any other classes I can find about programming, since nobody has the luck you have had on getting a job in programming after college to practice with Live events, at least I keep trying by practicing until I get that opportunity.

And yes, an error log will be helpful since I cannot debug a publish website but I can only observe the console on inspect for errors. And I do not do what you probably think of every programmer women , we treat debugging like playing dolls as you say it in your own words: "Debugging is not "run it and see if it looks right"

AND if you manage this forum, take me out of here since I cannot do it. I do not need your BS.
 
Kudos to you for continuing to practice and improve! I wish everybody was trying to do that! Keep on working on it and add to your portfolio to either show or discuss in your interviews. You are on the right track!

My first comments were not meant to be insulting or mocking. They were meant in all seriousness. If you used the ?? operator, then that would meant that you did it deliberately and should know about what kind of impact it would have in your code. If on the other hand, you just copied the code from someone else and took the the use of the ?? on blind faith, then you would need to understand why it was used and what effect it would have.

I didn't even know you were a woman programmer. My comment about "run it and see if it looks right" is from years of participating in forums like this where various posters would say that they have spent countless hours "debugging" their code, but when asked specific details, it comes out that their were actually just running their code, rather than debugging their code. So my comment was just applying generically to everybody says they were "debugging", but not showing any evidence of trying to trace through the logic and values of their code.

For logging, there's no need to log just to the console. You can use log4net or various other logging libraries to write out to a file, database, Windows event log, or email. If you don't have direct access to web host and you log out to a file, does the web host have a support intake where you can request that they send the log file back to you? Or does the web host provide FTP access so that you can download the file yourself? (There was one system I once worked on which didn't provide any of these and I was forced to write all my logging into a hidden label field. That was a painful way to debug.)

I'm sorry if you want to leave the forum, but please do persist with the art and science of coding. We need more female programmers. I've worked with several brilliant female programmers. They brought the extra element of patience and attention to detail to higher levels.
 
The core issue here lies in how your web application is trying to serve images when it's published on the server compared to running locally.

Here's an explanation of potential mishap:

Understanding the Difference Between Local and Server Environments

Local (Works):
When you run the application on your local machine, your code (string baseImagePath = @"\\WCUPOBPROC1-A\Old_Check_Images";) is executing directly on your computer. Your computer has access to the network path \\WCUPOBPROC1-A\Old_Check_Images. When your code retrieves an image from this path and likely serves it through your Images.aspx page, it's processing the image data on the server-side (your local machine in this case) and sending it as part of the HTTP response to your browser. The browser sees the image as part of the page content, not as a file it needs to fetch directly from a network path. The URL https://localhost:44339/Images.aspx reflects the request to your local web server process.

Server (Doesn't Work): When you publish the application to the server (https://fnweb.wescom.org/), the code is now executing on the web server. The web server process (usually running under a specific user account like "IIS AppPool" or similar) needs to have permission to access the network path \\WCUPOBPROC1-A\Old_Check_Images. This is the most common reason for this type of issue – the server process doesn't have the necessary network permissions that your local user account does.

Browser's Misinterpretation: The browser errors you're seeing (GET https://fnweb.wescom.org/Old_Check_Images/no-image.png 404 (Not Found)) indicate that the browser itself is trying to request the image directly from a URL that mirrors your internal server-side path (/Old_Check_Images/no-image.png). This is incorrect. The browser has no way to directly access a network share (\\WCUPOBPROC1-A\Old_Check_Images) from its end. It should be getting the image data through your Images.aspx page, similar to how it works locally.

The 404 errors happen because:
  1. The browser is trying to request images using a URL (https://fnweb.wescom.org/Old_Check_Images/...) that doesn't correspond to a physical directory or a correctly configured virtual directory on the web server containing those images.
  2. Even if the browser could somehow interpret that URL, the underlying web server process likely lacks the permissions to access the network share \\WCUPOBPROC1-A\Old_Check_Images to retrieve the image files.
Possible Solutions to aid you:

Common ways to fix this issue:

Configure IIS Application Pool Identity for Network Access: This is the recommended server-side approach.
  • On the web server, open Internet Information Services (IIS) Manager.
  • Go to "Application Pools".
  • Find the application pool that your website (fnweb.wescom.org) is using.
  • Right-click on the application pool and select "Advanced Settings...".
  • Find the "Identity" setting, which is likely set to a built-in account like "ApplicationPoolIdentity" or "NetworkService".
  • Change the Identity to a domain user account that does have read permissions to the network share \\WCUPOBPROC1-A\Old_Check_Images. You will need to provide the username and password for this domain account.
  • Important Security Note: Grant this account only the necessary read permissions to the image share. Avoid using highly privileged accounts.
Serve Images Directly from the Web Server (Less Ideal for Large Shares):
  • Copy the images from the network share \\WCUPOBPROC1-A\Old_Check_Images to a physical directory on your web server.
  • Configure a virtual directory in IIS for your website that points to this physical directory on the server. You could name the virtual directory "Old_Check_Images".
  • Modify your application's code to generate image URLs that point to this virtual directory (e.g., /Old_Check_Images/image.jpg). This might require significant code changes depending on how your Images.aspx page is generating image references. This approach is less ideal if the image share is very large or frequently updated, as it requires synchronization.

Modify Images.aspx to Stream Images: Ensure your Images.aspx page is correctly reading the image data from the network path on the server-side and writing it directly to the HTTP response output stream with the correct Content-Type header (e.g., image/jpeg, image/png). This way, the browser receives the image data as part of the page content or as the direct response to an image request targeting Images.aspx with parameters identifying the image, rather than trying to fetch the image file itself. Based on your local success, it seems you're already doing something similar, but double-check that the server-side code is indeed able to read the file from the network path.

Potential Troubleshooting Steps:

Verify Network Access from the Server:
Log in to the web server machine with the user account you configured for the application pool identity (if you chose option 1). Try to access \\WCUPOBPROC1-A\Old_Check_Images through Windows Explorer. If you cannot access it, you have a network permission issue independent of IIS.

Check IIS Logs: Examine the IIS logs on the web server for more detailed information about the 404 errors. The logs can sometimes provide substatus codes that offer more clues.

Simplify and Test: Create a simple test page on the server that just tries to read a single image file from the network path using the same code logic as your Images.aspx page. This helps isolate whether the issue is with accessing the network share or with the image rendering part of your Images.aspx page.
In summary, the problem is most likely that your web server's application pool identity does not have permissions to access the network share containing the images. Configure the application pool identity in IIS with a domain account that has the necessary read permissions on \\WCUPOBPROC1-A\Old_Check_Images. I hope this helps out. Have a good day.
 
The core issue here lies in how your web application is trying to serve images when it's published on the server compared to running locally.

Here's an explanation of potential mishap:

Understanding the Difference Between Local and Server Environments

Local (Works):
When you run the application on your local machine, your code (string baseImagePath = @"\\WCUPOBPROC1-A\Old_Check_Images";) is executing directly on your computer. Your computer has access to the network path \\WCUPOBPROC1-A\Old_Check_Images. When your code retrieves an image from this path and likely serves it through your Images.aspx page, it's processing the image data on the server-side (your local machine in this case) and sending it as part of the HTTP response to your browser. The browser sees the image as part of the page content, not as a file it needs to fetch directly from a network path. The URL https://localhost:44339/Images.aspx reflects the request to your local web server process.

Server (Doesn't Work): When you publish the application to the server (https://fnweb.wescom.org/), the code is now executing on the web server. The web server process (usually running under a specific user account like "IIS AppPool" or similar) needs to have permission to access the network path \\WCUPOBPROC1-A\Old_Check_Images. This is the most common reason for this type of issue – the server process doesn't have the necessary network permissions that your local user account does.

Browser's Misinterpretation: The browser errors you're seeing (GET https://fnweb.wescom.org/Old_Check_Images/no-image.png 404 (Not Found)) indicate that the browser itself is trying to request the image directly from a URL that mirrors your internal server-side path (/Old_Check_Images/no-image.png). This is incorrect. The browser has no way to directly access a network share (\\WCUPOBPROC1-A\Old_Check_Images) from its end. It should be getting the image data through your Images.aspx page, similar to how it works locally.

The 404 errors happen because:
  1. The browser is trying to request images using a URL (https://fnweb.wescom.org/Old_Check_Images/...) that doesn't correspond to a physical directory or a correctly configured virtual directory on the web server containing those images.
  2. Even if the browser could somehow interpret that URL, the underlying web server process likely lacks the permissions to access the network share \\WCUPOBPROC1-A\Old_Check_Images to retrieve the image files.
Possible Solutions to aid you:

Common ways to fix this issue:

Configure IIS Application Pool Identity for Network Access: This is the recommended server-side approach.
  • On the web server, open Internet Information Services (IIS) Manager.
  • Go to "Application Pools".
  • Find the application pool that your website (fnweb.wescom.org) is using.
  • Right-click on the application pool and select "Advanced Settings...".
  • Find the "Identity" setting, which is likely set to a built-in account like "ApplicationPoolIdentity" or "NetworkService".
  • Change the Identity to a domain user account that does have read permissions to the network share \\WCUPOBPROC1-A\Old_Check_Images. You will need to provide the username and password for this domain account.
  • Important Security Note: Grant this account only the necessary read permissions to the image share. Avoid using highly privileged accounts.
Serve Images Directly from the Web Server (Less Ideal for Large Shares):
  • Copy the images from the network share \\WCUPOBPROC1-A\Old_Check_Images to a physical directory on your web server.
  • Configure a virtual directory in IIS for your website that points to this physical directory on the server. You could name the virtual directory "Old_Check_Images".
  • Modify your application's code to generate image URLs that point to this virtual directory (e.g., /Old_Check_Images/image.jpg). This might require significant code changes depending on how your Images.aspx page is generating image references. This approach is less ideal if the image share is very large or frequently updated, as it requires synchronization.

Modify Images.aspx to Stream Images: Ensure your Images.aspx page is correctly reading the image data from the network path on the server-side and writing it directly to the HTTP response output stream with the correct Content-Type header (e.g., image/jpeg, image/png). This way, the browser receives the image data as part of the page content or as the direct response to an image request targeting Images.aspx with parameters identifying the image, rather than trying to fetch the image file itself. Based on your local success, it seems you're already doing something similar, but double-check that the server-side code is indeed able to read the file from the network path.

Potential Troubleshooting Steps:

Verify Network Access from the Server:
Log in to the web server machine with the user account you configured for the application pool identity (if you chose option 1). Try to access \\WCUPOBPROC1-A\Old_Check_Images through Windows Explorer. If you cannot access it, you have a network permission issue independent of IIS.

Check IIS Logs: Examine the IIS logs on the web server for more detailed information about the 404 errors. The logs can sometimes provide substatus codes that offer more clues.

Simplify and Test: Create a simple test page on the server that just tries to read a single image file from the network path using the same code logic as your Images.aspx page. This helps isolate whether the issue is with accessing the network share or with the image rendering part of your Images.aspx page.
In summary, the problem is most likely that your web server's application pool identity does not have permissions to access the network share containing the images. Configure the application pool identity in IIS with a domain account that has the necessary read permissions on \\WCUPOBPROC1-A\Old_Check_Images. I hope this helps out. Have a good day.

Wow! Just Wow! this explanation has more sense now, since I have been changing the code 3 times and in all of each version works very well in my local but once I published it, it gives me the 404 Error.
I will do as your recommendations and let you know. Thank you so much for that detail information since I am lacking of web services knowledge.
 
Last edited:
Back
Top Bottom