I need my web app to target the .net framework 4.6 so web services use tls 1.2 by default

I need my .net web application to target the .net framework 4.6 so web services use tls1.2 by default

I did not write the initial application but have taken over its maintenance for the past few years.

in the web.config there is the following code

      <compilation debug="true">
        <add assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.ServiceModel.Activation, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Runtime.Serialization, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.ApplicationServices, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Configuration, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Xml, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Services, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Core, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Drawing, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Services.Client, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Services.Design, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Entity, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Design, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

Open in new window

I am not sure why this is there and the following code is commented out:

    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>

Open in new window

can anyone explain it to me
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chinmay PatelChief Technology NinjaCommented:
I am not sure who or why the compilation and runtime tags are commented but if you want to target framework 4.6 you can change it in the comments.

Also are these the correct web.config? Maybe in Release/Prod different set of web.config is being deployed.
jackbensonAuthor Commented:
So you can have the code "add assembly="System, Version=" as well as targeting 4.6 uncommitted?
Chinmay PatelChief Technology NinjaCommented:
Yes. Please Refer to: https://blogs.msdn.microsoft.com/webdev/2012/11/19/all-about-httpruntime-targetframework/

<httpRuntime targetFramework="4.5" />
The effect of this attribute is twofold. First, it controls the CLR’s quirks mode behavior, just like the <supportedRuntime> element does in a console application.

Second, <httpRuntime targetFramework="4.5" /> is a shortcut that allows the ASP.NET runtime to infer a wide array of configuration settings. If the runtime sees this setting, it will expand it out just as if you had written the following:

    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />
      <compilation targetFramework="4.5" />
      <machineKey compatibilityMode="Framework45" />
      <pages controlRenderingCompatibilityVersion="4.5" />

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

jackbensonAuthor Commented:
you never answered this question:

So you can have the code "add assembly="System, Version=" as well as targetFramework="4.6" uncommitted?
Chinmay PatelChief Technology NinjaCommented:
I think I started my last answer posted on 1st June 2018, with Yes and it was the only question you asked. So that Yes was the answer to your question.
jackbensonAuthor Commented:
Thank you. I added the targetFramework="4.6" and now it is using tls1.2 by default.

Can i delete the references like:
 "add assembly="System, Version="

Or could they still be needed?
Chinmay PatelChief Technology NinjaCommented:
They might be needed. As I explained in earlier answer, 4.6 targetFramework is the instruction for ASP.Net to infer the settings... while Add Assembly references is used to explicitly refer to an assembly. So if your code depends on it, you will start getting errors.
jackbensonAuthor Commented:

Would the error happen at compilation or runtime? Compilation is easier to fix obviously
Chinmay PatelChief Technology NinjaCommented:
I believe it will be at runtime.
jackbensonAuthor Commented:
Thank you
Chinmay PatelChief Technology NinjaCommented:
Glad I could help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.