RadControl disappear and unrecognized tag prefix - asp.net

i need to enhance the application which developed by other colleagues, the source code located at share folder such as \10.1.1.1\App1
and i had map the share folder as network drive such as T: drive
my colleagues can open the apps by VS and work properly, but when i open it by VS2010, it cannot display the RadControl in Toolbox, display unrecognized tag prefix error message and cannot reference telerik function in code behind.
i had tried many methods that found on forum and website but doesn't work. e.g.
Using Caspol.exe to grant .NET applications rights to a remote ...
Caspol.exe –m –ag 1.2 –url file://\10.1.1.13/App1/* FullTrust
Caspol.exe –m –ag 1.2 –url file://\T:/* FullTrust
Add reference to web.config
Remove dll from bin folder

refer Telerik.Web.UI assembly and register the tagprefix in the web.config or directly into the page:
<system.web>
<compilation debug="false" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
<pages>
<controls>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" />
</controls>
</pages>
or in the aspx page:
<%# Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

Related

How do I encrypt the Telerik Rad Editor viewstate?

The viewstate or application's pages are already encrypted but looking at the Burp output of the response from a POST to the Telerik.UI.DialogHandler (ImageMananger) it seems the Telerik view state in the response appears not to be. See attached image.
Burp output
We've generated and specified the DialogParametersEncryptionKey, ConfigurationEncryptionKey, and ConfigurationHashKey keys in the site level web.config as described in article https://docs.telerik.com/devtools/aspnet-ajax/controls/editor/functionality/dialogs/security. This didn't change the viewstate.
The machine key in IIS is set for auto-generation.
I'm only assuming the Telerik viewstate can be encrypted because what I've read seems to imply that, but I haven't found a clear example so I'm not sure.
Can you please change the TargetFramework of the application to 4.5 or above and test again:
> <compilation debug="false" targetFramework="4.8" />
> <httpRuntime targetFramework="4.8" />
> <pages viewStateEncryptionMode="Always" enableViewStateMac="true">
> <controls>
> <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" />
> </controls>
> </pages>
> <httpHandlers>
It is also a must to set viewStateEncryptionMode="Always" enableViewStateMac="true" in the page directive or the web.config.
Check out this product forum thread for more information: https://www.telerik.com/forums/can-the-rad-editor-viewstate-be-encrypted.

C#: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both ReportingServicesWebUserInterface.dll and Microsoft.ReportViewer.WebForms.dll

Having searched a whole lot of similair posts, workarounds, I decided to make my own post.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0433:
The type
'Microsoft.Reporting.WebForms.ReportViewer'
exists in both
'c:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\reportmanager\Bin\ReportingServicesWebUserInterface.dll'
and
'c:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll'
Update:
Most similair posts have as a problem that their 2 conflicting DLLs have a version 8.0.0.0 and 9.0.0.0, or so. Or that they reside in the TEMPORARY folder. I do not think that my problem can be solved similairly with such posts.
On our ReportServer there exists a Report.aspx, which renders a report. I want to replace this file with my own, to modify the page layout, like so:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="WebApplication._Default" %>
<%# Register
Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms"
TagPrefix="rsweb" %>
<!DOCTYPE>
<html>
<head runat="server"></head>
<body>
<div>
<form id="reportform" runat="server">
<div>
<rsweb:ReportViewer
ID='ReportViewerRoot'
runat='server'
ProcessingMode='Remote'
Height='100%'
Width='100%'
AsyncRendering='False'
SizeToReportContent='True'
/>
</div>
</form>
</div>
</body>
</html>
This requires a reference to MS.ReportViewer.WebForms.DLL
My Project.csproj file has this:
<Reference Include="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
I was not able to uninstall any DLLs in C:\WINDOWS, because it said it was required for other applications.
I have also tried to modify web.config, adding some dependentAssemnly, but not sure what would be useful (It was useful for version differences mentioned above).
Further I have these lines in web.config:
<compilation defaultLanguage="c#" debug="false" tempDirectory="C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\RSTempFiles\">
<assemblies>
<clear />
<add assembly="ReportingServicesWebServer" />
</assemblies>
</compilation>
Thank you for your input.
I am looking forward to receiving your suggestions.
The satisfying solution!
When inserting a ReportViewer object in the aspx, the DLL reference is automatically added (and points to the GAC WebForms). I need this reference (Couldn't succeed manually referencing to GAC DLLs), then I remove the ReportViewer in the aspx. Also, I add the reference to the conflicting DLL ReportingServicesWebUserInterface.DLL. This moves the problem (error output from post) to VS, in stead of only on the SSRS Server.
When adding a new ReportViewer() I will get the error in VS.
The solution is as follows: give the none-required DLL an alias (without actually using it in code). This will tell the compiler that this DLL is not to be used when using WebForms. See picture
Report.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="MyWebApplication._Default" %>
<!DOCTYPE>
<html>
<head runat="server">
<title></title>
</head>
<body>
<div>
<div style="background-color:Red;width:100px;height:100px;">Hoi</div>
</div>
<form id="formID" runat="server">
test
</form>
<div>haha</div>
</body>
</html>
Report.aspx.cs
public partial class _Default : System.Web.UI.Page
{
ReportViewer ReportViewerRoot;
protected void Page_Load(object sender, EventArgs e)
{
AddRV();
}
public void AddRV()
{
ReportViewerRoot = new ReportViewer()
formID.Controls.Add(ReportViewerRoot);
SetReportViewer();
SetServerReport();
}
public void SetReportViewer()
{
ReportViewerRoot.ID = "ReportViewerRoot";
ReportViewerRoot.ProcessingMode = ProcessingMode.Remote;
}
private void SetServerReport()
{
ServerReport serverReport = ReportViewerRoot.ServerReport;
// Set the report server URL and report path
serverReport.ReportServerUrl = new Uri("http://localhost/reportserver");
serverReport.ReportPath = Request.QueryString["ItemPath"];
serverReport.Refresh();
}
}
Reference source: Extern alias walkthrough
I resolve my problem
To Remove the One Assembly from my Web.Config
In My Case Version 10 and 11 is comes together.
I Remove below code from by Config
<add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
Also a reason this may occur is if you have nested applications. ie. App2 inside of App1.
App1's web.config might mess with App2's. Make sure that they don't reference different versions of the same Assembly.
Not in this answer, but in the next answer I have put the satisfactory solution!! :)
This very solution does work too but is not satisfying concerning the development-cycle/readability/maintainability.
My Report.aspx file contains nothing but this line:
<%# Page Language="C#" AutoEventWireup="true"
CodeBehind="Report.aspx.cs" Inherits="WebApplication._Default" %>
My Report.aspx.cs does contain code such as:
HtmlGenericControl body = new HtmlGenericControl();
HtmlForm form = new HtmlForm();
ReportViewerRoot = new ReportViewer();
Controls.Add(body);
body.Controls.Add(form);
form.Controls.Add(ReportViewerRoot);
My ReportManager/Web.config contains additional tags as:
<!-- added enableSessionState -->
<pages validateRequest="false" enableSessionState="true" />
<httpModules>
<clear />
<!-- added -->
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
</httpModules>
<httpHandlers>
<!-- added -->
<add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
P.s.:
In no way I am able to combine html-code in report.aspx with a reportviewer (neither aspx or cs).
Nor can I add the ReportViewer dynamically in the aspx by using <% AddRV(); %>
P.s.s.
The Web.config helped me solve these errors:
In remote mode, the Report Viewer control requires session state be enabled or Report Server connection information specified in the
config file.
The Report Viewer Web Control HTTP Handler has not been registered in the application's web.config file. Add to the system.web/httpHandlers
section of the web.config file.
Includes in web.config a tag dependentAssembly to force the specific version:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
Go to
HKEY_CLASSES_ROOT\Installer\Assemblies\Global
search for the assembly and delete complete row by right click over that and choose delete.

How to register tagPrefix in app.config

in my ASP.net project's web.config I register the tagprefix cr as follows:
<pages>
<controls>
<add tagPrefix="cr" namespace="CrystalDecisions.Web" assembly="CrystalDecisions.Web,Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
</controls>
</pages>
I would like to start using configuration specific app.configs, but if I include the same setting in the app.config I get an error at compile time saying that the tagprefix is unrecognized
How can I force recognition of the tagprefix when it is in app.config instead of web.config
app.config is not used in a web project; anything you put in that file might as well not exist; ASP.NET and IIS completely ignore that file.

how to upgrade code to a new version of third party control

I have a web application in asp.net 3.5 where i have been using some third party controls i.e. Devexpresv9.2
and on the pages where i am using these controls i normally has to call the register tag on the page markup like for ex:
<%# Register Assembly="DevExpress.Web.v9.2, Version=9.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<%# Register Assembly="DevExpress.Web.ASPxGridView.v9.2.Export, Version=9.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>
Now i have updated the version of devexpress controls installed on my machine and it has stopped working because the version installed on my machine is v10.0 but my code is looking for v9.2
Please advise how can i modify my code in such a way that in future if i install another version then i don't have to modify all the pages and references again. May be something in web.config that can help me or anything generic??
Thanks
Use the project converter which is designed for this. It is located under the Windows Start Menu at "Develper Express V2010 vol1 -> Components -> Tools -> Project Converter". This will automatically change all of your references to the current version.
Project Converter Documentation
I think you answered your own question. You don't need to add the assembly reference on each page, put it in web.config.
<system.web>
<compilation>
<assemblies>
<add assembly="DevExpress.Web.v9.2, Version=9.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a">
<add assembly="DevExpress.Web.ASPxGridView.v9.2.Export, Version=9.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a">
</assemblies>
</compilation>
<pages>
<controls>
<add namespace="DevExpress.Web.ASPxCallback" assembly="DevExpress.Web.v9.2" tagprefix="dxcb">
<add namespace="DevExpress.Web.ASPxGridView.Export" assembly="DevExpress.Web.ASPxGridView.v9.2.Export" tagprefix="dxwgv">
</controls>
</pages>
</system.web>

Namespace removed in web.config not removed in a page with master

I have defined this in the web.config of a subdirectory
<namespaces>
<remove namespace="App"/>
<add namespace="Tom"/>
</namespaces>
App is imported in the parent web.config file, Tom and App have classes with the same names.
To avoid errors resulting from ambiguous class names I removed the App namespace from the sub-directory where the Tom namespace is used.
However the namespace App is still imported on content pages that have a master page outside the Tom directory. This causes the aforementioned errors.
Here is my dir structure
-Root Directory
--Default.master
--web.config (App is added in web.config)
--Tom Sub-diretory
---web.config (App is removed in web.config)
---Content page that uses Default.master (Here is the problem)
---Page without master (Works OK)
Any solutions?
Suppose you have the following in the root web.config:
<namespaces>
<add namespace="App" />
<add namespace="Tom" />
</namespaces>
And in your sub web.config:
<namespaces>
<remove namespace="App" />
<add namespace="Tom" />
</namespaces>
There will be no problem to use the class in .aspx pages in the sub-folder even if they derive from a master page in the root folder but you won't be able to use it in the master page. In the root master page you will need to fully qualify the type: <%= App.DuplicateType %> or <%= Tom.DuplicateType %>.
What about explicitly prefix the usages with the namespace? That should always work.

Resources