0

Goal: Have resource load on LOCAL site, not just PRODUCTION site.

Summary: I have a C# .NET Chat application that loads into an iframe in an Angular site. It works fine on PRODUCTION but I am having trouble getting everything to run on my VM (particularly, certain resources won't load at the proper location)

LOCAL Chat Site (on my VM): localhost:7078

PRODUCTION Chat Site: www.site.com/chat

Relative path to resource: "/chat/content/images/file.png

  • If I change this in the .aspx code, it makes the LOCAL site work, but breaks the PRODUCTION site
  • Want to keep /chat/ for the Production site, but LOCAL does not work with that

On LOCAL, Get error: "GET http://localhost:7078/chat/Content/images/file.png 500 (Internal Server Error)"

  • Actually loads at: /content/images/file.png

I have worked at this for days, looking up information about IIS and applicationhost, application path, relative path, virtual directories, etc. Every solution errors out in some way. I've looked through Microsoft documentation, SO articles, blogs, youtube vids, etc.

I have tried altering the applicationhost.config, web.config, ProjectURL, etc. This is what they look like prior to any changes:

applicationHost.config: (from \Solution.vs\config)

<site name="ChatServer" id="3">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Folder\Subfolder\Application\ChatServer" />
    </application>
    <application path="/chat" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Folder\Subfolder\Application\ChatServer" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:7078:localhost" />
    </bindings>
</site>

web.config:

  <system.web>
    <!-- Classic Mode (IIS 6 and Visual Studio) -->
    <httpHandlers>
      <add path="websync.ashx" verb="*" type="FM.WebSync.Server.RequestHandler" />
    </httpHandlers>
    <httpRuntime maxRequestLength="20000" executionTimeout="300" />
    <compilation targetFramework="4.6.1" debug="true" />
    <pages controlRenderingCompatibilityVersion="4.0" />
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <!-- Integrated Mode (IIS 7+) -->
    <handlers>
      <add path="websync.ashx" verb="*" type="FM.WebSync.Server.RequestHandler" name="WebSync Handler" preCondition="integratedMode" />




    <remove name="ExtensionlessUrlHandler-Integrated-4.0" /><remove name="OPTIONSVerbHandler" /><remove name="TRACEVerbHandler" /><add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /></handlers>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="20480000" />
      </requestFiltering>
    </security>
  </system.webServer>

I'm sure there is something annoyingly simple that I am missing, could someone please help point me in the right direction?

angleUr
  • 449
  • 1
  • 8
  • 27
  • Are you able to see some logs, check if you are trying to change something that is denied in system applicationhost.config file – Anirudha Gupta May 04 '19 at 01:27
  • "Relative path to resource: */chat/content/images/file.png*" That isn't a relative path. – John Wu May 04 '19 at 01:49
  • Use a tool like Fiddler to actually read the 500 response body. Never guess what's the culprit when you don't even see the big picture. – Lex Li May 04 '19 at 05:01
  • @JohnWu , I am going based off W3Schools definition https://www.w3schools.com/html/html_filepaths.asp – angleUr May 06 '19 at 15:59
  • It’s relative to the domain but not the folder. Your production site has a root folder that does not exist when you run as localhost . You need a relative path that is relative to the current directory, not the relative to the root. – John Wu May 06 '19 at 17:05

0 Answers0