Increasing capacity of sending file

By default is 4 MB, if we need more just:


<httpRuntime targetFramework=”4.5.2″ maxRequestLength=”1048576″ executionTimeout=”3600″ />


<requestLimits maxAllowedContentLength=”1073741824″ />

ASP.NET Failed deploying project on server

If you have error with deploying project on server you might have problem with privileges of exporting files. Add to project_name.csproj file in section PropertyGroup line like bellow:


Tip: If you not see *.csproj in your Solution Explorer just right click on project name and pick Unload Project then another right click on name project show context menu with Edit name_project.csproj

Hide DIV with DropDownList

Sometimes we need to hide some static part of the view. With help comes by jQuery and CSS.
First we need add script like below:


$(‘.extensionFields’).change(function () {
if ($(this).val() == ‘1’) {
else {


Use ordinary DropDownList with ignition CSS Class: extensionFields

@Html.DropDownList(“Id”, null, htmlAttributes: new { @class = “form-control extensionFields” })

Create DIV class name divrek and style display:none attribute to hide on start everything what is in div:

<div class=”divrek” style=”display:none”>Every thing that you wont to hide</div>

and now when we choose Id with value 1 contents of devrek suddenly appears.

Prevent duplicate records with seed

Prevent duplicate records when you use seed method in migration.
Originally in Migrations/Configuration.cs we can use:

p => p.FullName,
new Person { FullName = “Andrew Peters” },
new Person { FullName = “Brice Lambson” },
new Person { FullName = “Rowan Miller” }

But when we configure adding record (like sample above) every time when we making new migration (add-migration) record are duplicate. In this case need to use:

if (!context.tableModels.Any())
var defaultTYP = new List<tableModels>
new tableModels{name = “1”, text = “some text”},
new tableModels{name = “2”, text = “some text”},
new tableModels{name = “3”, text = “some text”},
new tableModels{name = “4”, text = “some text”},

defaultTYP.ForEach(tableModels => context.tableModels.Add(tableModels));

Observations: ALTER TABLE statement conflict

If you add another table to your project with 1-to-many relationships you may meet an error sound like:

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “FK_dbo.tableModels_dbo.idModels_admIdModelsId”. The conflict occurred in database “aspnet-dwmp1-20170323101827”, table “dbo.tableModels”, column ‘IdModelsId’.

Solved of this problem lies in content of table where you hook up your new table. In other words: delete content from your old table before you connect new one.

Some commands: Rollback migration

1.In Package Manager Console command Get-migrations return listing with migration names that you made:


2. Update db for earlier state:

Update-Database –TargetMigration: <name-from-listing-above>

3. Delete file with incorrect migration from your migrations folder in Solution Explorer.

4. Create new correct migration and update db.