Images and Script not working on deployment environment - asp.net-mvc

Everything works fine on my development environment, but when from production environment it doesn't load images, and also giving error of "$" is undefined on $.document jquery function.
The site is built using ASP.NET MVC.. there is "Images" folder on root, and "Scripts" folder on root as well.
I have checked the permissions on these folders and IIS users are given read access over there.
Not sure, but its worth mentioning that I am using thinktecture as an identity server.

Please double check your jQuery reference on that page using View Source (Ctrl + U), if it's there?
OR
may be you had reference wrong path for jQuery on that page .
OR
may be you have using multiple jQuery files on page and your files is Conflict with others.
you can debug your problem using Firebug in Firefox.
Hope this will help you.... :)

Related

Razor views not generating html after deploying Umbraco 7.2 in IIS 7

I am new to Umbraco, so I started creating a site to play a bit with it. While I had my site running on IIS express (either from VS or WebMatrix) everything worked fine. After deploying the site to IIS 7, the razor views of the front end are display in plain text, meaning that I actually see Razor syntax in the browser. Umbraco back office is working perfect though, except when I hit preview, in that case I get the plain Razor syntax again. I then try to deploy a simple new MVC project to IIS and the Razor engine worked just fine, so I guess is not a problem in IIS but in Umbraco configuration. Is there any configuration tweak I need to take care in Umbraco configuration to solve this problem? Thanks in advance for the help.
I also tried to deploy it in the IIS of my local development machine (the same in which it runs OK in IIS-express) which has the right framework and everything and I got the same cshtml display in the browser.
After struggling a bit more with the problem I found the issue causing this behavior. After installing the starter kit a lot of files are generated in the folder and subfolders of the solution. In order to publish the solution to generate the contents of your website the VS project needs to have all these files included as project files. I found out that some views were excluded of the project and thus not being generated when publishing. I included the missing views and double check that all important files were part of the project and problem solved.

visual studio not updating html / javascript to server / browser

This is an MVC 4 app using the Hot Towel SPA template. Whenever I change anything in the HTML and/or javascript the only way I can get the new code to display is to clear the browser cache. F5, cntrl-F5, shift-F5, nothing works.
I'm not normally a web dev and just learning this. I've done regular MVC before and not had this issue, maybe it has to do with where the HTML and javascript is in my project (i.e. in the /App folder) ?. I'm going nuts trying to figure this out.
I can completely delete an HTML file and run the app and it still runs as it did. Clear cache and run and I then get the update.
It's running using IIS express using Firefox, Chrome, IE...
Thanks..
In Opera and Chrome (and possibly others), you can disable caching while in 'development mode'.
While in DevTools, the 2nd option in the Settings menu is
Disable cache (while DevTools is open)
Go to your web.config file and make a change in it.Its not matter what change you make.For example type a character and then delete it and build the project and run it again.I hope it works.
I also experienced this issue and turns out it was related to caching.
If using Chrome DevTools, you can simply disable cache by navigating to the Network Tab and ticking Disable Cache
This will only disable the cache when Dev Tools is open.
ctrl+shift+F5 will do the trick! Seems like browser cache is part of the problem :)
in my case iis express not updated site, but site , created by iis Manager worked correctly?
possible solution for this problem is
set "use this 64 bit version of iis express for web sites and projects" option at visual studio
it located at options->Projects and Solutions->Web projects
I found that I had the .js file open in the Chrome Developer Tools -> Sources View.
When I closed the file there and refreshed the page the new .js file showed up as expected.
The browsers cache by default. You can turn off caching in your browser to get the changed files.
I had an issue with moved .ts & .html files on the server and had to:
stop debugging
clear the whole output/dist folder inside my ClientApp
start debugging again
Ctrl-F5 to force the cache to refresh on the browser
Simply disabling the browser's cache, or forcing the .net app to recompile, or even running ng serve had no effect.
None of the above listed methods works consistently and if one considers that different browsers are used in the task pane depending on Windows version/build used then you may have to clear the cache of a different browser in each case.
However, it seems that the real issue is not so much browser caching as it is VS deciding which files to deploy to the local IIS Express server used for testing/development. In many cases, when pressing the "Start" button, modified html and/or js files won't make it to the local deployment even if you also modify the web.config file.
The way I made this work consistently is I selected the web application project (in Solution Explorer), opened properties, clicked the "Package/Publish Web" tab and then under "Items to deploy" I selected "All files in this project".
Works fine for me!
If you just want to test locally You can try
A) Create Virtual Directory
Follow below path: Project / Properties / Web
Find Servers section
Click on Create Virtual directory
B) Follow below path: Project / Properties / Web
Find Servers section
Click on Drop down and change the selected value between Express and Local
Then Create Virtual directory
Following are some of the options that we can use to solve the problem.
ctrl + shift + r (This will do a hard refresh of your current tab)
ctrl + F5 (This will force the cache to refresh on the browser)
Stop debugging and Change the web.config file and run again
Stop debugging and clean the project, Rebuild it and run the project
In case disabling the cache and editing the web.config file does not work.
Simply close the solution and reopen it and try it. Strange, but it worked for me.

How to deploy Umbraco 5 website

I hope I'm asking this question in the right place. I also asked on umbraco forum, but did not get any response yet.
I'm having problem with deploying my Umbraco 5 website to external hosting.
On local machine, I used Umbraco 5 template for VS2010, which works fine (although it's quite slow).
When I publish to live server I get 500 error.
So far, i've tried installing fresh copy of umbraco on hosting (works fine).
I copied config files in hive provider folder (in App_Data), to point umbraco to my hosting database. That does not throw any exceptions yet. Problem starts when I copy views and partial views over - umbraco then finds the template defined in database and tries to load that.
It's worth mentioning that I also copied my project.dll file into bin directory on the server - the reason for that is because I have added new controller which inherits from surfacecontroller (in /Controllers folder).
Please let me know if I'm doing something wrong.
Cheers
Sebastian
It is not any different than deploying a MVC3 website.
There are quite a few questions with exactly that signature here on so.
Visual studio even has a few tools to help you in the process.
The publish function is found right clicking the project in the solution explorer.
If you use the template for developing, you have a working umbraco solution locally right?
If that is the case, it is easier to just deploy / publish the entire site intead of copying bits into another umbraco solution.
Publish tool
When using that tool, remember that umbraco has quite a few config files etc. and they all need to be included. So it is probably the easiest to just export all files in the folders, by changing "which files to include" setting in publish tool. That will unfortunately include all your .cs files too, but later they can be filtered out of the publish process.
First make it work, then make it awesome :)
The same goes for compilation mode, i have found that release mode sometimes breaks things, so for now just keep it in debug mode.
Then later when you have it working, you can change to release mode for a small performance gain.
Stuff to remember
include all necessary files
change connectionstrings
copy databases
custom errors, you don't want your visitors to see YSOD's with your internal debugging info.
disable tracing and debugging!
After reading this, you should go on and look for other more elaborative resources too.
"umbraco then finds the template defined in database and tries to load that" is key point to me
whatever the version you follow the templates and doc types are the backbones of umbraco ( from you website I know that you are aware with above more then me.. but repeating.) I mean you have created new website but there are no relative Templates and Doctype yet you try to use them in views and subviews and that caused the problem.
To do that please create tempalte and doctype same as is in you staging site and this problem will be solved.
Even better kick-start you development with new site only and make replica of that after defining doc-type and templates to your staging.
I hope i can explain my point.
Thanks,
Jigar
I've had problems in the past deploying Umbraco 5 projects. When you deploy an Umbraco 5 website to a new server and before you switch the website on in IIS, navigate to \App_Data\ClientDependency and delete any XML files that are there. Next, navigate to \App_Data\Umbraco\HiveConfig and delete the ConfigurationCache-*.bin files.
Once you've done that, recycle your Application Pool and start your website.

ASP.NET MVC3 IIS can't get stylesheets to load

I am having trouble getting my local II7 to load stylesheets when running a default 'File/New' MVC3 website. When I run the site using Visual Studio everything works great. I created an IIS7 website pointed to the root folder of the MVC website. The site comes up, but no stylesheets load. My app pool is set for .NET 4 and Integrated mode.
The same issue was described in this topic, but the fix didn't help me (I already have the 'serve static content' setting checked).
ASP.Net MVC & Local IIS Issue Loading Stylesheets
Any direction is appreciated!
This was solved by enabling Anonymous Authentication in IIS, then right-clicking that node and choosing Edit and choosing Application Pool Identity. Everything loads correctly now. With fiddler I noticed I was getting 401 errors on the stylesheets/js files, so I knew I had a security issue.
In your layout page have the style sheet like:
<link href="#Url.Content("~/folder/style.css")" type="text/css" rel="stylesheet" />
This should help by making it relative to your applications root the #Url(Content("~/ part.
Another thing to check is that Static Content is enabled in Windows Features - this catches me out every time. In Windows 7:
Open Control Panel
Select Programs > Programs and Features > Turn Windows features on or off
Expand Internet Information Services > World Wide Web Services > Common HTTP Features
Check "Static Content"
Click OK and wait before retrying.
As #Mike said, I am almost willing to bet that the problem is that the path to the CSS file is different when you run local than when you run on the server.
Where are your CSS files located at?
For example, if your root IIS folder is c:\inetpub\wwwroot...are your CSS files under
c:\inetpub\wwwroot\somefolder\content\style.css or under
c:\inetpub\wwwroot\content\style.css
?
I had this problem too, and none of the solutions here (or anywhere else that I could find) helped.
The Solution
It turned out that my CSS files were downloaded from an external source in zip format. The files were copied and pasted from the zip file to my IIS directory using Windows Explorer. If you unzip the file first before doing the copy operation, then it won't mess up the permissions and you will be able to view them in IIS.

ASP .Net MVC - Images not being shown in published build

I am developing an ASP .Net MVC application and on my dev machine, the application runs as expected and, more importantly, the images mentioned in the CSS file are displaying correctly too.
However, when I publish this application to a testing server, the web app runs fine, but the images are not shown.
If I modify the URL in IE when testing the output from the test server, the image is returned, meaning that the file is there but it just won't appear within the view page when using the site normally.
I have tried alternative servers too, but the result is the same.
To confirm, here's a line from the CSS page referencing the image...
background-image: url('/Content/Images/Logo/myLogo.jpg');
Any suggestions?
Cheers
Brett
The URLs are not correct, likely due to the fact that you are publishing in a subfolder and so they are no longer at the root of the server. I usually use Url.Content( "~/Content/Images/..." ) to build the url instead of hard-coding it. That way it will take into account the routes when building the path.
Example:
<img src='<%= Url.Content( "~/Content/Images/banner.jpg" ) %>' alt="Banner" />
I had the same issue, but I found the reason why it was forcing authentication on the Contents folder.
When a user is not logged in yet, they are classified as Anonymous Authentication. In IIS7 (which is what I am using, guessing it is the same in IIS6) you need to open the authentication window in features view. Then edit the Anonymous Authentication, to use your application pool identity, or the default one, just make sure that user has permissions to read in that folder.
That fixed it for me, hope it works for you.
Possible relative paths are wrong...Possible that they are wrong for CSS file itself. You can use FireBug to see if CSS loaded correctly, then you can examine image request, often in such situations you will see red(error) items. This could help to localize problem.

Resources