C#, RDLC

RDLC : Web.config Settings for ReportViewer

We, .Net Developers always do many kind of reports using RDLC . But while developing , we get the below error If we do not add web.config entries correctly .

We may get runtime error like below :::

The Report Viewer Web Control HTTP Handler has not been registered in the application’s web.config file

add name=”ReportViewerWebControlHandler” preCondition=”integratedMode” verb=”*” path=”Reserved.ReportViewerWebControl.axd” type=”Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”

To resolve this issue , add these below Nodes to Web.Config.

  <system.webServer>
    <handlers>
      <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </handlers>
  </system.webServer>

And

    <system.web>

    <httpHandlers>
      <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler,   Microsoft.ReportViewer.WebForms, Version=10.0.0.0,   Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"  />
    </httpHandlers>

Cheers 🙂

Standard
Uncategorized

Get connection String from Web.config in ASP.Net and C#

“Human Brain is amazing , When I don’t want to save something inside my Brain , It also does not want to save it and literally it does not do that. ” – This line is true for me 🙂

And I always go to my previous written Code + Config file (Or Web) to know how to get Connection String from Web.config . I don’t want to use my Processor of the Brain a minimal percentage for this , And I guess , There are also so many people out there in the world , so this Post is for you guys 🙂

So in my Web.config/App.config file , I will add the below thing .

  <connectionStrings>   
    <add name="connectionStr" connectionString="Data Source=MASOOM-PC;Initial Catalog=ProjectManagerDB;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

And Below is the C# code for that .

string connectionString = ConfigurationManager.ConnectionStrings["connectionStr"].ConnectionString;

We can also add Node to AppSettings in Web.config and can get it easily .

<appSettings>
    <add key="EmailTo" value="emailid@yahoo.com" />
  </appSettings>

And this is how we can get this in C#

string emailTo = ConfigurationSettings.AppSettings["EmailTo"];

In future , I will definitely come to my own Blog for this 🙂 Cheers

Standard