ASP.NET MVC Page not render when specify action - asp.net

I'm having the following problem in my application.
When access a view, specifying only the controller, the entire layout of the master page is rendered correctly:
Eg:
localhost:50904/Contact
But when I specify the action, the layout of the master page is not rendered:
Eg:
localhost:50904/Contact/Index
localhost:50904/Contact/Success
I checked the HTML generated in both cases, and the generated HTML is correct. What can I be doing wrong?

Possibly you have references to .css files and those references are relative. Change the references to the .css files to start with / to make them rooted to the root of the site.

Press F12 and look for any errors in the console or network tabs.
You my find that the css or js files are not loading, check the paths if you see any errors.

Related

how do i solve issues regarding external style sheet link which is not in the same directory of the programming file,but works?

I programmed a page (read index.php) including front end and back end operations,and in between i included a link -<link rel="stylesheet" href="style.css" type="text/css">, but there is no effect on the front end application whether I put this css file in the same directory of index.php or delete it. But when I remove the link from the programming page then the front end page is affected. So, how do I conclude this situation? Please anybody help me. I don't understand how the css file works when it is not in the directory where programming page lies.
Based on the information given it sounds like the file is being included from a cache.
Deleting the file on the server wouldn't affect the page render since there is a locally cached version of the file but deleting the link would prevent the browser from loading the cached version.
Sometimes when working on your localhost you have to put the entire path of the CSS file, not just it's normal location as you do when on a live website. Copy your entire path in the href on the link tag and see if it works.
Normally, if the file is in the same place as your index, you put the href the same way it is written in your example above. If your CSS file is in another folder, you would put ../style.css instead. Writing like that, will move up one folder.

My CSS works in the inline section but not as an external stylesheet

I am currently trying to use CSS to stylize my application in Apex 5. The problem I am having is that when I write my CSS code in the "inline" section of any page in the application, then the CSS code works, but if I write the CSS code on Notepad and then upload the file and reference the file within my application, then the CSS code does not work. I have written several lines of CSS code, so I'll just post one small section of it as a sample so that you all can see my format:
body{
font: bold 12px/16px "Times New Roman";
}
I have uploaded the file in the Static Application Files section of the Shared Components page of the application. I have then tried referencing the file in different places, such as at the page level and user interface level, but nothing has worked so far. I'm very new to CSS, so any insight would be greatly appreciated. Thank you in advance!
After uploading the file have to be displayed in the list of static files. The list of files have a column Reference, which contain a string like this: #APP_IMAGES#test.css. Copy this string and put it, for example, on the page in the section CSS - File URLs. This should work.
Then make sure that file reference works. Open your page and take a look on a list of CSS files. The same functionality is present in all browsers, but it is accessible by different ways. In IE:
Press F12.
Open Network tab.
Press "Enable network traffic capturing" (a green triangle in the left top corner).
Reload the page. A list of files appears.
Find your file in a list:
If the file is not present, then you copied an incorrect link, or you copied it into an incorrect place, etc.
If the file is present, normally it should have status 200 (the Result column). If a status is not 200, there could be a lot of reasons (depending on the status).
If the file is present with the status 200, your CSS property doesn't work, because it is overridden with another CSS. To define with which one, go to the Dom Explorer tab.
You can try this approach:
On server, go to ORACHE_HOME/apex/images/css (path can be different, but you can find it by .css extension)
Put you file here
Id editor, in page properties, go to the CSS -> File URLs section
Write path like this: /i/css/new.css (i - in general, alias for your images directory)

Asp.net defalut style sheet edit/delete?

I am creating a new asp.net web application.
Application contains a default master page i.e site.master.
That Master page has link to site .css that was the by default css attached.
link href="~/Styles/Site.css" rel="stylesheet" type="text/css"
I removed site.css from my project(exclude from project) but its functionality survive. How this is happening? Why the styles gets not deleted or removed??
I am Using IE11.
Exclude from Project is not good way to do this.
Remove that file completely then you will not have that file loaded.
after that remove reference from master page or anywhere you are giving it.
Do CTRL + SHIFT+ F for entire solution search and search for that file name. so remove that references if you find.
now about browser cache issue. remove browser cookies and history. Or you have one more option like open your website and load with b y pressing
CTRL + F5. it will load your website totally fresh and with new code completely.

Bootstrap not rendering on index page on particular url

I have created an MVC project in ASP.NET 4.5 and designed the index page of home controller using bootstrap. When I browse to the url
http://localhost:59772/,
it gets rendered perfectly. But when I go to
http://localhost:59772/Home/Index,
which is essentially the same page, bootstrap doesn't gets rendered and everything appears as plain text without any styling. I have properly set the default values in route config as
Controller = home, action = Index
. Any help is appreciated.
The links are searched for in the current directory you are browsing. If you are on
localhost:12345/
It will look for resources in the project folder and if you are browsing
localhost:12345/home/index
It will look for resources in home folder, even though both the url's render the same page. Thats why bootstrap etc doesn't gets loaded the second time.

Image disappear when url route

I am writing a web page to show image (image is dynamically generate by .Net charting) in a web. I have used the asp.net web forms URL routing to navigate to this page. Once I use the URL routing the image appear on the page. Anyway this is working fine for normal page browse.
More than likely your link to the image is using a relative path, and once you introduce routing you are working with a URL structure that appears to be deeper nested in the folder structure than it is.
When linking to the image for display I would recommend using root relative path something like /Images/MyFile.jpg rather than ../Images/MyFile.jpg, or similar.
This way if your route changes, and additional "folders" appear in the route, the link will still work.

Resources