VS 2005 Web Site Project Template Annoyance - asp.net

I recently inherited a project that was done with the "web site project template" (which I hate by the way). I have always worked with the "web application template" which I love. I'm perplexed by something that I found in the project though. There is custom control instances throughout all the pages like this:
<cc1:MarketingItem runat="server" ID="BannerAd" />
Nothing too fancy there, right? What really irritates me is that it works just fine without any control registration tags at the top of any of the pages for "cc1" or code behind it's just magic! As you can imagine this makes tracking down the locations of these controls more work, and frankly a pain. My question is how is this even possible? And why did Microsoft introduce such an annoying inconsistency with this project template?

You'll likely find it registered in web.config (system.web>pages>controls i believe). You can globaly register controls there just as you would on the page.
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</controls>
</pages>

Related

ClaimsAuthenticationManager is not invoked

I'm facing a weird issue with the WIF ClaimsAuthenticationManager. I have registered the custom implementatin of the ClaimsAuthenticationManager in the web.config file:
<identityConfiguration>
<claimsAuthenticationManager type="<namespace>.CustomClaimsTransformer,<assembly>" />
<claimsAuthorizationManager type="<namespace>.CustomAuthorisationManager,<assembly>" />
....
When i run the application in the IISExpress the authenticate method of the ClaimsAuthenticationManager gets invoked. However, it's not being invoked ever since i deployed the application on IIS 7.5.
Is there any configuration that needs to be done?
In the system.webserver part of your web.config do you have the ClaimsAuthorizationModule set,
eg
<add name="ClaimsAuthorizationModule" type="Microsoft.IdentityModel.Web.ClaimsAuthorizationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
For .NET 4.5 you have to add this:
<add name="ClaimsAuthorizationModule" type="System.IdentityModel.Services.ClaimsAuthorizationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
ClaimsAuthenticationManager is not invoked automatically. One needs a plumbing code for that unless they are using WS-Federation.
You can do it in an PostAuthenticateRequest event handler for the HttpApplication.
A good example is located in the http://github.com/thinktecture/Thinktecture.IdentityModel.45 project. Search for ClaimsAuthenticationHttpModule.cs which invokes it.

How to use chart control's assemblies in application without installing it?

I am using a web application in which there is a chart control. I had installed the Microsoft chart control exe and Visual studio add on.
The problem is that when I upload the application on the server, there is a problem with the two assemblies missing System.Web.DataVisualization.Design.dll and System.Web.DataVisualization.dll.
So, I want to uninstall the Microsoft chart control exe & Visual studio add on, and instead only use the DLL in the application by giving reference in it.
Now, how do I define chart control on an ASPX page? How do I register the assemblies on the ASPX page and how can I get the chart control from it?
I think you can just add the DLL's to your Bin directory of your website.
Installing the chart controls locally simply adds the DLL's to your computer somewhere (I think). And I believe that the Add-In is to give you support for design mode. It doesn't install anything specific to your projects.
However, you may need to register the controls either on the page or in the web.config. For example, here is the registration of the AjaxControlToolkit controls in the web.config:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<pages>
<controls>
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
</pages>
</system.web>
</configuration>
I have solved the problem.
First, add the library System.Web.DataVisualization.dll as reference.
Then, add the following line in web.config, inside <httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
You may see DataVisualization.Charting.ChartHttpHandler in red, it will build and run successfully. This may be a ReSharper bug.

I don't have ListView in toolbox, intellisense, and doens't work in code

I am using ASP.NET v3.5 and Visual Studio 2008. For some reason ListView doesn't appear in my toolbox, it doesn't show up in intellisense when coding, and if I try to include one anyways I can't access it from code behind (will give error saying it isn't declared). What am I missing here.... where is my listview!?
Update: I have v3.5 installed but for some reason the project is using 2.0... now on to figure out how to change that. In my project references several things say version 3.5.0.0 and several say 2.0.0.0 .... is there any way to update everything to version 3.5 ???
Try changing your project's TargetFramework to 2.0 and follow VS.NET's instructions to reload project. Then change the TargetFramework back to 3.5 and follow instructions.
It worked for me to get the asp:ListView back into intellisense.
Not sure what gets VS.NET in this state though.
Does your project reference System.Web.Extensions? You will need to do so to get at the new ListView control.
Make sure you have a FQ assembly reference to the 3.5 version of System.Web.Extensions, in the web.config section.
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Also make sure you have a FQ assembly reference in the <system.web><compilation><assemblies> web.config section too.

Registering User Controls in web.config Shows Error, But Controls Work Anyway

This has been bugging me all morning and I can't even figure out where the error is.
In the current web site I am developing (it's not a web application, in case it makes a difference, there are user controls declared as follows:
<controls>
<add tagPrefix="uc1" tagName="TransitLinkAdmin" src="~\controls\TransitLinkAdmin.ascx"/>
<add tagPrefix="uc1" tagName="TransitLinkList" src="~\controls\TransitLinkList.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageAdmin" src="~\controls\WelcomeMessageAdmin.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageDisplay" src="~\controls\WelcomeMessageDisplay.ascx"/>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
So far so good, right?
But when I try to add one of these controls to a page, I get an error telling me that the control cannot be found. So why when I run the page, I can use the control?
The designer is telling me that it cannot find the user control file and it is using the path from the web.config file, so it must be looking at it in some fashion.
If I register the control directly in the page, no problems there.
My assumption (and we now how that works) is that there is some compilation error for the site as a whole that is preventing the intellisense from working.
Thanks in advance, all.
Just a complete guess, but maybe it is because you are using backslashes instead of forward slashes? Try:
<add tagPrefix="uc1" tagName="TransitLinkAdmin" src="~/controls/TransitLinkAdmin.ascx"/>
<add tagPrefix="uc1" tagName="TransitLinkList" src="~/controls/TransitLinkList.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageAdmin" src="~/controls/WelcomeMessageAdmin.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageDisplay" src="~/controls/WelcomeMessageDisplay.ascx"/>
Are you using resharper?
I am not sure what version, but somewhere along the way this artifact had happened.
try updating to the last version.
btw they have an early access program where you can download builds (decent quality), and be updatd with the latest features and fixes.
link to early access program
Close visual studio
Move to the location:
In Windows 7:
C:\Users\Pavel\AppData\Roaming\Microsoft\VisualStudio\10.0\ReflectedSchemas
In Windows XP:
C:\Documents and Settings[your username]\Application Data\Microsoft\VisualStudio\10.0\ReflectedSchemas in windows XP
Delete all the files in that folder location. Note that it is completely safe to delete files in this location.
Then reopen visual studio.
This should solve your problem.

Sys is undefined - ajax issue in IE 7 only

I have a weird issue that only seems to be affecting IE 7. The web site is a 3.5 c# asp.net website that utilizes ajax and the ajax control toolkit deployed to a win 2003 server. Everything appears to be correct in the web.config. In fact, everything works perfectly in IE6 and Firefox 3. It is only in IE7 that I get the dreaded sys is undefined error.
Also, the site appears to be working fine for IE7 on a different installation of the same code. That server is running win 2003 with very similar setups.
Since this appears to be a server issue, are there any kind of settings that would prevent ajax-enabled sites from displaying properly in IE7?
I know you said that everything appears to be correct in web.config, but still check it again on that server for this:
<add verb="GET,HEAD"
path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false"/>
in the <httpHandlers> element.
If it is there, then in IE7 do View Source, and grab one of the ScriptResource.axd script reference URLs and just paste it into the browser and see what it comes back with.
Believe it or not, but emptying the temporary internet files solved the problem. I hate things like this!
I had this error when we moved to a new version of the AJAX Control Toolkit, and the new dll for that library didn't propagate out correctly when I rebuilt. So clearing the temp inet files is what I had to do also.
Are you using the "Combine Scripts" functionality of the AJAX Toolkit Script Manager? It's known to cause problems with some browsers/proxies, leading to the very error you're describing. I think it's enabled by default in 3.5, so you might want to look at shutting it off and seeing if your problems persist.
Are you sure that it is only IE7? Maybe other browsers are supressing the error. Firebug on Firefox might bring this to the surface.
The two times I have seen something like this were
a) using jQuery in the same project as ASP.NET Ajax, here jQuery's noConflict method helped out
b) Check the position of the ScriptManager on your page, make sure that it isn't being included in a Content Page but referenced above in a Master Page or something like that
Hope this helps
Try placing your javascript code below <asp:ToolkitScriptManager>
None of the suggestion worked for me, but when added the following under <system.web>, it worked!
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

Resources