Increasing capacity of sending file

By default is 4 MB, if we need more just: <system.web> … <httpRuntime targetFramework=”4.5.2″ maxRequestLength=”1048576″ executionTimeout=”3600″ /> … </system.web> <system.webServer> … <security> <requestFiltering> <requestLimits maxAllowedContentLength=”1073741824″ /> </requestFiltering> </security> </system.webServer>

Query by viewbag

in controller: ViewBag.db = <some_query>; in view: foreach (var item in ViewBag.db) { @Html.ActionLink((string)item.table.some, “Index”, “Edit”, new { id = item.someID }, null) }

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: <PropertyGroup> <IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination> </PropertyGroup> Tip: If you not see *.csproj in your Solution Explorer just right click on project name and pick Unload Project then another right click […]

Unique name of uploaded files

If you want to prevent situation that you have the same name of upload files use this example: var fileToSave =  DateTime.Now.ToString(“yyyyMMddHHmmssfff”) + “_” + Guid.NewGuid().ToString(“N”) + “-” + SomeYourModelsId + “.pdf”;  

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: $(‘.divrek’).hide(); $(‘.extensionFields’).change(function () { if ($(this).val() == ‘1’) { $(‘.divrek’).show(); } else { $(‘.divrek’).hide(); }; }; }); Use ordinary DropDownList with ignition CSS Class: extensionFields @Html.DropDownList(“Id”, null, htmlAttributes: new { […]

Prevent duplicate records with seed

Prevent duplicate records when you use seed method in migration. Originally in Migrations/Configuration.cs we can use: context.People.AddOrUpdate( 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 […]

Some commands: Creating an executable from a Python Script

Installing PyInstaller pip install pyinstaller Building the executable: pyinstaller.exe –onefile –windowed If you have problem error 14001 on Windows XP use this: pyinstaller   – – clean   – – win-private-assemblies   – F   – – windowed   – – name giodo    – – icon=icon.ico

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 […]

Some commands: Rollback migration

1.In Package Manager Console command Get-migrations return listing with migration names that you made: Get-Migrations 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.