The client and server cannot communicate, because they do not possess a common algorithm


I recently faced an interesting issue when trying to fetch data from third-party API. When trying to connect to the API endpoint, I received the following error message:

“An error occurred while making the HTTP request to https://<API endpoint>. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.” Inner exception was “Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.”

Solution :

The issue came up when we setup a Thycotic Secret Server on a hardened OS. On the OS TLS 1.0 was disabled for security reasons, however at the moment the used Microsoft SQL server didn´t speak TLS 1.1 or TLS 1.2. So the error message:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 – The client and server cannot communicate, because they do not possess a common algorithm.)

After TLS 1.0 was enabled on the Thycotic Server the installation could be performed without issues. So make sure that your Microsoft SQL environment is up to date and supports TLS 1.1/1.2 if you wish to disable TLS 1.0.

Advertisement

Issue: Password field returned empty in edit mode


This is as per design. Passwords are not filled to prevent accidental resubmits, and to prevent the page from containing unencrypted passwords.

Here is the solution

@Html.PasswordFor(model => model.Password,new{@Value=Model.Password})

OR
@Html.PasswordFor(model => model.Password, new { placeholder = "********" })

This will put some 'visual' asterisks in the input box which will be disappeared when the user starts entering an actual value.

Hope this help!

EXT.NET : Getting selected RadioGroup value through inputValue


How to get selected value from RadioGroup in EXT.NET

Consider following sample code

On the server side I would like to be able to do something similar to this:

var value = typeRadioGroup.CheckedItems[0].InputValue;

to get the selected value directly and proceed with the code instead of calling e.g.

if (dailyRadio.Checked)
// do something
else if (weeklyRadioChecked)
// something else

Hope This help !

Entity Framework : Could not load type System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider


When you have separate class library projects for Data access layer which contains your entity model and when you are giving reference of this class library to your web application on build you may get following error

Could not load type System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider

You can solve this error by following line assembly reference in your website project webconfig file

<system.web>
    <compilation debug="true" targetFramework="4.5">
        <assemblies>
            <add
                assembly="System.Data.Entity.Design, Version=4.0.0.0,Culture=neutral,
                PublicKeyToken=B77A5C561934E089" />
        </assemblies>
    </compilation> 
    <httpRuntime targetFramework="4.5" />
</system.web>

 

Microsoft.VisualStudio.Editor.Implementation.EditorPackage’ package did not load correctly: Visual Studio 2012


The Problem

When starting Visual Studio …

  • … by loading a solution file, no windows display and the Solution Explorer remains empty.
  • … you get a bunch of error messages thrown in your face.
  • … you can only add text in the editor, not remove it.
  • … some other strange, unexplainable thing prevents you from using Visual Studio as you normally would.

TerminalServerIssue

 

The Solution

If you are having one of the issues above and neither restarting Visual Studio or rebooting your machine helps, then there is a large change your Component Model Cache is corrupt and you need to delete that folder using following steps

So, here is how you fix it:

  1. Close Visual Studio (if you haven’t done so already out of despair)
  2. Open a file explorer window and navigate to your AppData folder. You can get there by:
    1. In the search bar, type %APPDATA%/.. and press enter
    2. Alternatively, navigate to C:\Users\\AppData
  3. Go into Local\Microsoft\VisualStudio\<version> where <version> is 12.0 for Visual Studio 2013.
  4. Delete the ComponentModelCache folder.

Hope it helps !

 

EF code first – Model compatibility cannot be checked because the database does not contain model metadata


This suggests that migration table is out of sync (even if your data isn’t), and that’s been part of the db schema now (since 4.3 I think – under system tables).

There could be many reasons and ways to experience that error , but most of the time…

The problematic part is some combination of manually backing/restoring the full database with code changes alongside – I’m not entirely certain as to why always.

In short, even if Db-s are the same migration table data might not be – and hash comparison may fail (still full restore sounds like good enough – but you have ‘two sides’).

What works for me is to use
Update-Database -Script

That creates a script with a ‘migration difference’,
which you can manually apply as an SQL script on the target server database (and you should get the right migration table rows inserted etc.).

If that still doesn’t work – you can still do two things…

a) remove the migration table (target – under system tables) – as per http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-automatic-migrations-walkthrough.aspx comments in there – that should fail back to previous behavior and if you’re certain that your Db-s are the same – it’s just going to ‘trust you’,

b) as a last resort I used – make a Update-Database -Script of the full schema (e.g. by initializing an empty db which should force a ‘full script’),
find the INSERT INTO [__MigrationHistory] records,
just run those, insert them into the database,
and make sure that your databases – and code match,

that should make things run in sync again.

(disclaimer: this is not a bullet proof to work at all times, you may need to try a few things given your local scenarios – but should get you in sync)

Also this will work

I found the code will work by changing

static LaundryShopContext()
{
Database.SetInitializer<LaundryShopContext>(
new DropCreateDatabaseIfModelChanges<LaundryShopContext>());
}
into

static LaundryShopContext()
{
Database.SetInitializer<LaundryShopContext>(
new DropCreateDatabaseAlways<LaundryShopContext>());
}

 

GridView: Findcontrol from HeaderTemplate/ItemTemplate


How to find item template control in GridView?

Dim chkHeader As CheckBox = DirectCast(gridView1.Row.FindControl(“chkHeader”), CheckBox)

How to find control from header template in grid view?

For example If you want to find checkbox available in header template of gridview

<asp:GridView ID=”gridView1″ runat=”server” AutoGenerateColumns=”False”><Columns>

<asp:TemplateField >

<HeaderTemplate>

<asp:CheckBox ID=”chkHeader” runat=”server” />

 </HeaderTemplate>

</asp:TemplateField >

</Columns>

</asp:GridView>

Solution:

Find Header control using following line of code

VB.NET Code:

Dim chkHeader As CheckBox = DirectCast(gridView1.HeaderRow.FindControl(“chkHeader”), CheckBox)

C# Code:

CheckBox chkHeader = (CheckBox)gridView1.HeaderRow.FindControl(“chkHeader”);

Hope this is help !

 

 

 

 

 

Cross-Domain requests in Javascript


jvaneyck

If you are developing a modern web-based application, chances are you:

  1. Are using javascript on the client side.
  2. Need to integrate with services that are not completely under your control (or that reside in a different “origin”).
  3. Have been confronted by this error message in your browser’s console:

XMLHttpRequest cannot load http://external.service/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://my.app' is therefore not allowed access.

Every time I need to integrate a web app with some external service or some server-side API I have no complete control over, I bump into this error. Google has not yet provided me with a concise description of the problem or an overview of alternatives to perform Cross-Domain requests, so this post will serve as a personal future reference.

View original post 1,911 more words