0
votes

I have developed DotNetNuke module using DotNetNuke C# Compiled Module Template in Visual Studio 2010. My module project is located under DesktopModules section in dnndev.

When I am designing any .ascx page(View.ascx) its automatically adding a web.config file in my project location. But I already have a web.config file where my dnndev is hosted and for conflicting two web.config file, I think there is being loading problem of my custom module in dnndev page.

My question is How to prevent auto generated web.config into my dnn module project? And How to read connection string from external web.config(dnndev hosted web.config) for my module project?

2

2 Answers

1
votes

The connection string is stored in the default connection string collection, and DNN provides a few methods to get to it as well. Here are a few options.

  • ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString
  • DataProvider.Instance().ConnectionString - if Using DAL+
  • From within the SqlDataProvider.cs file in your template if using the older DAL method

As for your issue with the web.config. Typically the only time that this gets added by Visual Studio is if you change the compilation target. Visual Studio sees a web project and assumes that you need a web.config. You can just delete it and it shouldn't come back.

0
votes

If you're doing DNN module dev with the DAL (data access layer) the template already provides you access to read the connection string from the web.config in the SQLDataProvider.cs file

As for the web.config being added in VS2010, that I believe was an old bug with the templates that you will have to live with unless you upgrade to the latest templates which work MUCH better in Visual Studio 2013.