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

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

Open in new window


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

  <!--
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  -->

Open in new window


can anyone explain it to me
LVL 1
jackbensonAsked:
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 Technical 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.
0
jackbensonAuthor Commented:
So you can have the code "add assembly="System, Version=4.0.0.0" as well as targeting 4.6 uncommitted?
0
Chinmay PatelChief Technical 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:

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

Open in new window

0

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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

jackbensonAuthor Commented:
you never answered this question:

So you can have the code "add assembly="System, Version=4.0.0.0" as well as targetFramework="4.6" uncommitted?
0
Chinmay PatelChief Technical 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.
0
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=4.0.0.0"

Or could they still be needed?
0
Chinmay PatelChief Technical 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.
0
jackbensonAuthor Commented:
Thanks

Would the error happen at compilation or runtime? Compilation is easier to fix obviously
0
Chinmay PatelChief Technical NinjaCommented:
I believe it will be at runtime.
0
jackbensonAuthor Commented:
Thank you
0
Chinmay PatelChief Technical NinjaCommented:
Glad I could help.
0
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
ASP.NET

From novice to tech pro — start learning today.