I have a small web application which uses themes. The themes work on host, so on preinit, if the host = a, load x theme, if the host = b, load y theme.
In my code this looks like:
If request.url.host.contains("a") Then
Page.Theme = x
Else
request.url.host.contains("b") Then
Page.Theme = y
I have a url which is a.abc.com and another which is b.abc.com (well it is this structure, but the letters are meaningful/company names). Problem is (and I have done host == ""), when I debug my site on localhost (another clause in the above if block where host = localhost), the style renders perfectly. Alignment of elements are perfect as I expect with the numerical values I have provided for width, margins, etc in the css. But when I use the publish tool of VS2008 (with updatable ticked), and upload to a.abc.com, which has the same stylesheet as localhost (a copy in its own folder), there are all sorts of alignment issues as if I have done no work. Why do my styles render incorrectly # runtime? If it helps, I am using VS2008 Pro Edition, IIS6 and Windows Server 2003.
What is frustrating is that the page source indicates the theme is loading ok, as it is referenced in HTML head. So when I publish, the theme for a.abc.com is loaded and referenced. Other than all this information, there is no obvious sign of what the problem is. I haven't tried to conventionally reference a single CSS file in the ASPX markup, but if I did and this worked, then it doesn't explain the problem either, anyway.
Thanks
Are you setting the Theme early enough in your code? A Theme must be applied to a page very early in the request lifecycle, in the PreInit event, if you do it in code-behind.
Yep, it is on page preinit.
I think it is to do with forms authentication. If I view (not debug) the login page, it picks up the localhost theme and everything is displayed correctly. The login control is in the middle of the page, as it should be, etc.
But if I debug the page and, as you'd expect, the login page is the start/default page, the login control appears to the left as it does when I deploy and the source indicates the css for the appropriate host has been picked up - only when I debug, there is no style applied until I login.
Are you using the built-in web server? When running in ASP.Net Development Server, the styles in App_Themes won't be used on any unauthenticated page (such as Login.aspx or ForgotPassword.aspx). That's because the user doesn't have browse permissions on that folder yet, or the App_Themes folder lacks browsing permissions. Apparently, IIS handles this but Cassini doesn't.
Try adding this to web.config to let Themes and styles work before authentication.
Or, if possible, switch to running the app on IIS on your machine.
I have enabled and installed all the sub features in
Internet Information Services --> World Wide Web Services --> Common HTTP Features
This solved by Theme not working problem.
Related
I'm having a problem with a component used in a Sitecore solution on our Windows 7 workstations that is driving me batty.
In short, the component in question adds <script> tags to the page that load supporting JavaScript files. The src attributes are set to something like:
/path/to/scriptgenerator/?r=1234&p=asdf
Those paths are not working - I'm getting a 404 back.
You might thing "oh ... well, the path doesn't exist." But it does, and it also has a Default.aspx page in it. In fact, if I try the following path, the JS is generated and returned by the server:
/path/to/scriptgenerator/Default.aspx?r=1234&p=asdf
We're testing the site using IIS7.5, not Visual Studio's debugging web server. Of course, on the production machines, which are Win Server 2008, things work just fine.
The component in question is a third-party component and I have no access to the source code, so I can't just modify it to append default.aspx to the SRC path.
I have checked to verify that Default.aspx is set up as a default document for the site, and it is.
I tried to work around the problem using ISAPI_Rewrite, but for some reason, rules that I set up for /path/to/scriptgenerator are ignored.
I've tried the solution described in these questions, and that has no effect on my problem:
IIS 7 Not Serving Default Document
ASP.NET 2.0 and 4.0 seem to treat the root url differently in Forms Authentication
I'm really not sure what to try or look for next ... any suggestions?
Is this component set up within the same IIS Site as the Sitecore application?
If so, have you added path /path/to/scriptgenerator to IgnoreUrlPrefixes setting in web.config?
I am doing some work with Web.Routing, using it to have friendly urls and nice Rest like interfaces to a site that is essentially rendered by a single IHttpHandler. There are no webforms, the handler generates all the html/json and writes it as part of process request.
This works well for things like /Sites/Accounting for example, but I can't get it to work for the site root, i.e. '/'.
I have tried registering a route with an empty string, with 'default.aspx' (which is the empty aspx file I keep in my root folder to play nice with cassini and iis). I set RouteExistingFiles to false explicitly, but whatever I do when hitting the root url it still opens default.axpx, which has no code it inherits from, and contains a simple h1 tag to show that I've hit it.
I don't want to change the default file to redirect to a desired route, I just want the equivalent of a 'default' route that is applied when no other routes are found, similar to MVC.
For reference, the previous version of the site didn't use Web.Routing, but had a handler referenced in the web.config that was perfectly capable of intercepting requests for the root or default.aspx.
Specs: ASP.NET 3.5sp1, C#, no webforms, MVC or openrasta. Plain old IHttpHandlers.
Fixed my own problem: the issue is the integrated web server, Cassini or some such. Seems that it doesnt play nice with routing, and will by default simply return the default.aspx file or, if it is missing, show a directory listing.
Using IIS with a virtual directory works fine, but is annoying (frustrates code sharers because they need to set up new virtual directories when they open my app, and pollutes my own IIS instance. Bah. Probably what I'll do for the moment however, or setup a new application manually so I can use the domain host only path like what will exist in live.
An alternative is to use the updated version of cassini, seen here, which works if the default.aspx file is missing, but I have not worked out how to integrate it with visual studio yet. Any help would be appreciated, but its not a big priority given I have workarounds.
I realise that this is a really old post, but I just ran into the same problem using VS2012, so I'm posting this here just in case.
I solved the problem by installing IIS Express and setting the project to use IIS Express in Visual Studio. Solved the problem.
Greetings
i have a little problem with my ASP MVC application.
On my local development server everything works just fine but when i try to publish the application to an IIS 7.0 server it just displays plain pages without any styles / markups / images.
I put all those things in the /Content/ subfolder but when i try to access that folder on the production server it just returns me a 404 not found error.
I set the IIS server up with .Net 4.0 and followed the deployment guide on here: http://www.asp.net/learn/mvc/tutorial-08-cs.aspx
All views / controllers / classes seem to work just fine, the only thing which does not is the content subfolder and i cant see why.
Anyone got a suggestion what i could have overlooked or does anyone know that problem?
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.
Well, I added the IIS_IUSRs to the project directory and found the same problem:
CSS won't load and nothing from the content folder.
But it resolved the Unable to start debugging on the web server problem.
Then, I added the IUSR to the same folder and that fixed the problem. Now, I can see images, css styles and all that stuff.
This is because you are probably using a fixed path on the src, like: ../../Content/Styles/style.css. In MVC you should use the Url helper: Url.Content("~/Content/Styles/style.css").
Using the Url helper you should have no issues.
Been pulling my hair out all night with this one.
On W2K8, MVC2, .NET 4.0, and IIS 7 (using VS 2010)
Made sure that IIS_IUSRS had full rights to the root folder but still no go - css, js, images still not being accessed in rendering the page....
and then .... so simple:
In Features view for the site - defined MIME types for .js, .css, and .jpg - and voila!
Sweet!
p.s. my 1st mvc app - and I think I'm liking it...
Check the properties of your content folders...see if they are not 'copying locally' for some reason.
The folder that your virtual directory is pointing to gave to the user "All" reading properties.
We recently rewrote our company homepage and have come across a peculiar error. We have very few pages that need any code behind them, so we wrote the website in static HTML served out of IIS6. The few pages that need any code (Contact Us, with a contact form, for instance) are .ASPX pages.
The previous version of the website had more .ASPX pages, even if there was no code in the code-behind. One of those pages was "management.aspx", and in the new site this is, logically enough, "management.htm". We're smart enough to not just change the file extension -- we rewrote everything, it just has the name in common.
Here's the peculiar part: Even though every link in the entire website points to "management.htm", IIS6 continues to try and serve "manangement.aspx". I've reset IIS, stopped/started the Default Web Site under IIS6, deleted pages from "Temporary ASP.NET Files" and deleted out temporary GZIP files from the server as well. This isn't MVC or anything, so we have no explicit URL routing, and while I can see us having to implement static file handling in our web.config httpHandlers, I can't imaging that being a necessity.
What gives? Why is IIS6 still trying to serve the old "management.aspx" page when we're explicitly asking for "management.htm"? What can I do to fix it?
Your bindings have to be off somewhere... check top level for *, *.htm, managment.htm, etc. Then check virtual directories.
If you paste "http://yoursite/management.htm" in your browser and you get a YSOD, this is an IIS issue for sure.
Check if you still have the bin folder in the root of your site.
Do you get a 404 because it tries to load management.aspx and it's not there?
Check the Default Page on the Website/Virtual directory in Question, and if it exists remove the reference to manangement.aspx.
Seems like everything else works fine on my website but the images are not showing. No errors are being thrown either. Even the localhost default site image is not working. I have the static option turned on as well. Any ideas on how to fix this would be great.
You may have to turn Static Content on in World Wide Web Services / Common Http Features. This can be accessed via the 'Turn Windows Features on or off' section in the Control Panel.
See below for an example...
http://peterkellner.net/2008/04/01/iis7imageproblem/
When I get images not appearing it is because the files themselves don't have correct permissions. Go in and make sure that the files are inheriting permissions from their parent.