Subdomain does not load styles and scripts

Asked

Viewed 548 times

1

Good morning,

1- I created a new solution in Visual Studio 2012;

2- I created ASP.NET MVC 4 Web Application. I opted for a "BASIC" project, Framework 4.5 and the Razor engine;

3- I created the Home controller;

4- I created the Index.cshtml view;

The content of the Index.cshtml page has only one text and one debug

I didn’t do anything, just the main content of a "BASIC project".

Published, see the result:

What should I do for scripts and styles to load in the subdomain?

I appreciate the help.

1 answer

1

This is the subdomain source code on the date of this reply. Note that you have loaded scripts and css correctly into <head> in minified form:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="/imobiliaria589s42d78/Content/css?v=ji3nO1pdg6VLv3CVUWntxgZNf1zRciWDbm4YfW-y0RI1" rel="stylesheet"/>

    <script src="/imobiliaria589s42d78/bundles/modernizr?v=qVODBytEBVVePTNtSFXgRX0NCEjh9U_Oj8ePaSiRcGg1"></script>

</head>
<body>


<h2>Host</h2>
<h2>imobiliaria589s42d78.meudominio.com.br</h2>


    <script src="/imobiliaria589s42d78/bundles/jquery?v=JzhfglzUfmVF2qo-weTo-kvXJ9AJvIRBLmu11PgpbVY1"></script>


</body>
</html>
<html>
<div id="haackroutedebugger" style="background-color: #fff; padding-bottom: 10px;">
    <style>
        #haackroutedebugger, #haackroutedebugger td, #haackroutedebugger th {background-color: #fff; font-family: verdana, helvetica, san-serif; font-size: small;}
        #haackroutedebugger tr.header td, #haackroutedebugger tr.header th {background-color: #ffc;}
    </style>
    <hr style="width: 100%; border: solid 1px #000; margin:0; padding:0;" />
    <h1 style="margin: 0; padding: 4px; border-bottom: solid 1px #bbb; padding-left: 10px; font-size: 1.2em; background-color: #ffc;">Route Debugger</h1>
    <div id="main" style="margin-top:0; padding: 0 10px;">
        <p style="font-size: .9em; padding-top:0">
            Type in a url in the address bar to see which defined routes match it. 
            A {*catchall} route is added to the list of routes automatically in 
            case none of your routes match.
        </p>
        <p style="font-size: .9em;">
            To generate URLs using routing, supply route values via the query string. example: <code>http://localhost:14230/?id=123</code>
        </p>
        <p><label style="font-weight: bold; font-size: 1.1em;">Matched Route</label>: {controller}/{action}/{id}</p>

        <div style="float: left;">
            <table border="1" cellpadding="3" cellspacing="0" width="300">
                <caption style="font-weight: bold;">Route Data</caption>
                <tr class="header"><th>Key</th><th>Value</th></tr>
                    <tr><td>controller</td><td>Home&nbsp;</td></tr> <tr><td>action</td><td>Index&nbsp;</td></tr>
            </table>
        </div>
        <div style="float: left; margin-left: 10px;">
            <table border="1" cellpadding="3" cellspacing="0" width="300">
                <caption style="font-weight: bold;">Data Tokens</caption>
                <tr class="header"><th>Key</th><th>Value</th></tr>

            </table>
        </div>
        <hr style="clear: both;" />
        <table border="1" cellpadding="3" cellspacing="0">
            <caption style="font-weight: bold;">All Routes</caption>
            <tr class="header">
                <th>Matches Current Request</th>
                <th>Url</th>
                <th>Defaults</th>
                <th>Constraints</th>
                <th>DataTokens</th>
            </tr>
            <tr><td><span style="color: #c00">False</span></td><td>api/{controller}/{id}</td><td>id = </td><td>(empty)</td><td>(null)</td></tr><tr><td><span style="color: #c00">False</span></td><td>{resource}.axd/{*pathInfo}</td><td>(null)</td><td>(empty)</td><td>(null)</td></tr><tr><td><span style="color: #0c0">True</span></td><td>{controller}/{action}/{id}</td><td>controller = Home, action = Index, id = UrlParameter.Optional</td><td>(empty)</td><td>(empty)</td></tr><tr><td><span style="color: #0c0">True</span></td><td></td><td>controller = Home, action = Index, id = </td><td>(empty)</td><td>(empty)</td></tr><tr><td><span style="color: #0c0">True</span></td><td>{*catchall}</td><td>(null)</td><td>(null)</td><td>(null)</td></tr>
        </table>
        <hr />
        <h3>Current Request Info</h3>
        <p>
            AppRelativeCurrentExecutionFilePath is the portion of the request that Routing acts on.
        </p>
        <p><strong>AppRelativeCurrentExecutionFilePath</strong>: ~/</p>
    </div>
</div>

EDIT

The route is even considering bundling directories, which is wrong. Bundles are special references to your project.

I don’t know how you configure for Locaweb, but in your case what you solve is by referencing the static scripts and css (directory /Content/) or else using CDN.

As comments, one thing you can resolve is to specify the following in the file web.config:

<location path="." inheritInChildApplications="false">
  • Gypsy, good afternoon. First thank you for your help. So, in Chrome, if you press F12, and in the Network tab, press F5 vc will see that it does not load the scripts (404 Not Found), already in the domain everything loads normal. Even if you compare the Host text on the two pages you notice the difference

  • I’m doing this with a blank application like this because I realized that this is the problem q is affecting my application.

  • @Lucas Where are you hosting your application? You have control over the IIS dashboard?

  • So, it’s on Ocaweb, and I didn’t do anything. See: http://wiki.locaweb.com/pt-br/Como_publico_uma_aplica%C3%A7%C3%A3o_usando_asp.Net_mvc_%3F

  • @Lucas Editei the answer.

  • I understand, I will consider your explanation at Ocaweb, to try to resolve. When I make direct static reference without using Bundles the page is even right, but as my application has bootstrap and javascript, it does not validate Dataannotation. On the login screen, I click the button and nothing happens, does not validate and does not access the system.

  • How much did your suggestion use the CDN? I don’t know I’ll need to read about, but in advance using CDN in my application, has bootstrap, validations Dataannotations, the application is separated into layers BLL, DAL, MODEL.. has AREAS, will work using CDN?

  • It is that loading the references of other sites takes this problem from within the structure of Locaweb, and possibly solves the problem.

  • Cool Gypsy, I did not know this term CDN, I learned. Very well the night I will test, then I give a feedback if it worked. Thanks, for the help

  • Gypsy, you’re right. In hosting they say to put <Location path="." inheritChildApplications="false"> in web.config.

  • But now, load the scripts and styles, but I bumped into the following problem: Subdomain generates the following form: <form method="post" action="/immobiliario589s42d78/Admin/accountAdmin/login"> BRINGS PROBLEM does not find the CONTROLLER domain generates: <form=method"post" action="/Admin/accountAdmin/login"> OK and access the normal system and everything works Please help me what I need to do now. Thank you.

  • @Lucas Now is another problem. Please ask a new question with your new problem.

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.