AdBlock blocking CSS and Images on .NET 4.5 web site - asp.net

I created a new web site using the default web-forms web site template that comes with Visual Studio 2012. Just went to File--> New Website --> C# --> Asp.Net Web Site, and let it create it's basic template.
Then I hit F5 to debug and it runs fine and I get that default welcome page with the aqua green block, etc... but when I add it to IIS and browse to it using localhost/WebsiteName in Chrome, the AdBlock plugin blocks all of the CSS and Images so all I see is black-and white un-styled text. When I disable AdBlock, the styling and images return and it looks normal just like it did when debugging.
I have a feeling it has something to do with the Bundle Referencing, but I'm not sure what's going on.
What specifically is AdBlock blocking?
Why isn't it blocking it when debugging through Visual Studio, only when browsed to it via localhost/WebsiteName?
What can I do to prevent users with AdBlock from having this content blocked when it is clearly not advertising?

I must assume you have a matching rule in your Adblock config. If you Go to Adblock - Options and turn on "I'm an advanced user, show me advanced options." you should then be able to reload your page and go to "Show the resource list" from the Adblock button. All items on the page will be displayed, the blocked items will be in red and the matching filter shown.
Good luck.

Thanks for the tip. It turns out that AdBlock blocks anything matching /advertising/* and the actual name of my app is "Advertising" because it will be an advertiser management system for my organization. Looks like I need to find a new name for that folder. When debugging is only went to localhost:5538/ but localhost/advertising/default.aspx got blocked because of the word "advertising" in the path.

Related

.ASPX pages markups are opening in web browser

When I double click on .aspx pages in my web application project in VS2010, instead of showing the mark up in the ide the .aspx pages are opening in the web browser as shown below. The same is happening when I run my application it opens all the .aspx pages in the web browser along the application url i.e., http://localhost123456/default.aspx. I have to close all the other pages except the http://localhost123456/default.aspx to run/ test my application. Not sure what would cause this to happen. I am not able to find any solutions so far, any help is appreciated. I used the option View Markup (Rightclick on aspx page -> view Markup) to see the markup for now.
Update
As per Mike's answer I checked the options under Open with... and I do have a Internet Explorer (Default) set as shown in the following image. Not sure how did it got there.
Deleting the Internet Explorer (Default) option might be cumbersome if I have lot of .aspx pages , if there is a way to remove this option at once for all .aspx pages rather than right clicking on each and every .aspx and remove it that would be great.
As per #JB King suggestion I did checked the file properties and all the .aspx files are set with Opens with: Microsoft Visual Studio option as shown it the image below.
Right-click any .aspx file in the project, select Open With...
In the screen that pops up, select Web Form Editor, then click the Set as Default button.
Not sure how you got Internet Explorer as an option here, but if it is there, you can just delete it. It's not applicable for loading the aspx from disk. Rather, to see the rendered page in IE, you'd do View in Browser or Browse With... (in which you can set your default browser, as well).
Your address bar shows you're loading files directly from disk. This won't work. ASP.NET is not lilke static HTML. ASP.NET applications must be run from within a webserver. Install IIS and ensure ASP.NET is installed and configured, or use the Debugging Webserver (IIS Express) in Visual Studio.
If you look at the properties of the file, there should be a line of Opens with: that is where you want to have Visual Studio rather than Internet Explorer as the issue is with which programs are mapped to what file extension. Microsoft instructions if you want those as specific steps to do.

strange #.[some char] added to the page address in firefox

[Asp.net website, .net framework 4]
I noticed a strange thing in my web page address, With every new page requested the address of the page automatically attached with somthing like (#.UTedxFc5stU) at the end of the address after loading completed (maybe cause redirect too), this happend with only .net framework 4 applications,
and not happend with my other applications using 3.5 !.
this happend in firefox, chrome only, not with internet explorer.
this an example:
http://egypt.motorsyard.com/cars/used, open it in firefox and you will see somthing like this http://egypt.motorsyard.com/cars/used#.UTehGVc5stU
what is this, and how I stop it ?
Thanks for help.
Check your webconfig for url rewriting code.
i think this is URL redirecting issue.
Edit
If you have characters that look like #.TuomlFaZCSo in the URL those are address bar tracking codes. They provide a way to see how many people visit your site from users copying the URL from the address bar. If you have characters that include the name of a service, like #.TuomlFaZCSo.facebook then those are people returning from a link shared using that service.
To disable them using the client API, do this:
<script type="text/javascript">
var addthis_config = {
data_track_address_bar: false,
data_track_clickback: false
};
</script>
If you want to disable them using the Wordpress plugin look for their respective checkboxes on the Advanced tab of the AddThis plugin settings page.

CSS images not showing in ASP.NET MVC

In my ASP.NET MVC application, I am referencing background images via CSS. When I run it in the dev environment, they show up fine. But when I deploy it (using IIS 7.5) the images do not load at all. I have tried every combination of relative paths and background/background-image CSS tags, but nothing works. Here is my file structure and CSS:
File structrue:
Content
CSS file
images
image.png
CSS:
background-image: url(/images/bsb_header2.png);
I have also tried ../images/bsb_header2.png and ../../images/bsb_header2.png to no avail.
What is really strange is when I try to go to the image directly (i.e. www.website.com/images/image.png), I am redirected to a login page. Perhaps there is some access or security setting I'm missing? I haven't done anything with login controls yet (the default account view and controller are in my project but I haven't done anything with them yet) and I can view all my other pages just fine.
Update: I FINALLY figured it out. The image file in question was encrypted. Right click the image file and navigate to properties, click the advanced button on the general tab, uncheck "Encrypt contents to secure data", click OK, OK.
The tip off finally came when I noticed the file name was green in Windows Explorer. I see green file names all the time with no problems so I didn't think anything of it. Then I noticed it was the only green file in the entire web app folder. Put two and two together and it worked instantly. Thanks everyone for your help.
Please Add two users
IUSR,
IIS_IUSRS
to the publish folder and assign permission for them to read & execute
I FINALLY figured it out. The image file in question was encrypted. Right click the image file -> properties -> advanced button on general tab -> uncheck "Encrypt contents to secure data" -> OK -> OK.
The tip off finally came when I noticed the file name was green in windows explorer. I see green file names all the time with no problems so I didn't think anything of it. Then I noticed it was the only green file in the entire web app folder. Put 2 and 2 together and it worked instantly. Thanks everyone for your help.
Is it possible that IIS 7.5 was not installed correctly?
If you go to Turn Windows Features on or off - under:
Internet Information Services /
World Wide Web Services /
Common Http Features
there is a Static Content checkbox
is it checked?
see this link for screen-shot.
in css set "display: block"
.searchbtn
{
margin-top:-15px;
background-image:url(../images/icons/search.png);
background-repeat:no-repeat;
width:18px;
height:18px;
display: block;
}
The URL should be relative!
background-image: url(images/bsb_header2.png)
From your description, it appears as if the Request for the .png is getting routed to the ASP.NET/MVC engine instead of being served up by IIS.
Is it possible that the routing rules in the Global.asax are picking .png files? (I know this doesn't explain why it works in your dev environment).
Does it work if you add a ignoreRoute for .png files at the beginning of your route list in Global.asax? Something like below...
routes.IgnoreRoute("{resource}.png");
Had the same issue and finally found a solution.
In IIS open "Authorization Rules".
If there is nothing there, click "Add Allow Rule"
Choose "All Users" and hit OK

Flex application bookmarking problem/"#" at end of url

I work in an area where the business users heavily depend on bookmarks to access their work-related web applications. Our standard browser is Internet Explorer v6. We have a new Flex application - when you add the site to Internet Explorer Favorites, then later try to access the site with the Favorites link, we get the following error message: "internet explorer cannot open the internet site http://our url. Operation aborted". If we then bring up the properties for the link and remove the trailing "#' from the url, the link works.
What is this trailing "#", and can it be removed? Is there a way to have Internet Explorer bookmarking to work for this site (other than manually editing the bookmark)? The problem doesn't occur in Firefox (but not everyone has access to that browser).
The trailing # is used to provide information to your client-side framework. It was originally meant to provide the ability to link to anchor points in an HTML document. It has been "hijacked" by JavaScript frameworks to provide state information to Flash and Flex applications.
The primary benefit of using # to navigate is that the browser doesn't navigate off the current page - meaning you only need to load your framework once. Traditional URLs would force an entire page reload.
Most likely you can't remove it. You should be able to provide a means for a secondary URL scheme that encodes what you need in a query string (?foobar=1).
You will need to configure server-side processing to either redirect the user to the hash URL or load the necessary information via a JavaScript hook to your Flex framework.
You might also look into the new Google Chrome plugin for IE.
You can turn this off in the compiler parameters in Flex Builder. Go into the project settings, then in "Flex Compiler" uncheck the box that says "Enable integration with browser navigation".

ASP.NET theme not rendering correctly

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.

Resources