Tuesday, September 20, 2016

Intellisense in Visual Studio Package Manager Console

I think most of the people know about this but for information "TAB" key can be used to get intellisense help whenever needed.

Normally following commands have been used too often while using Package Manager Console.

Installing a Package:
Install-Package PackageName -Version versionNo

Uninstalling a Package:
Unintsall-Package PackageName -Force

-Force parameter can be used if you want to keep other dependent references for a package like in case of installing a newer version of a package.

Enabling Code First Migrations:
Enable-Migrations

This command can be used to enable code first migrations. Migrations folder gets created in the project which contains a Configuration.cs file having a Seed function and contains all the migration files whenever created.

Code First Migration Commands:
These commands can be found at this post: Code First Migration Commands

Let me know if need any further commands information.

Friday, June 5, 2015

Filezilla: The data connection could not be established: ETIMEDOUT - Connection attempt timed out

I am trying to connect with one of my website from FileZilla and I am getting the following error:

"The data connection could not be established: ETIMEDOUT - Connection attempt timed out"

I have tried many solutions but no solution has been found.

How to Fix:

At last I was able to figure out this issue which was an issue with Ftp connection settings. In FileZilla menu bar click on File=>SiteManager. Below is the image which shows what option needs to be selected in Site Manager:

Select "Only use plain FTP(insecure)" option from Encryption drop down selection.




Wednesday, January 30, 2013

Windows Service: Starting a Service on Installation

I have been working on a Window Service project and I need to start the service after it gets installed since I need to manually run it after installation. This is very frustrating for me since I have been testing the service also.

So I have found the following solution which I am going to share with you which solved my problem and Service gets started after installation.

Below is the code for the Installer class which I have used in my Service project:

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.ServiceProcess;


namespace Service
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
        public ProjectInstaller()
        {
            InitializeComponent();
            this.AfterInstall += new InstallEventHandler(ProjectInstaller_AfterInstall);
        }

        void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)
        {
            ServiceController sc = new ServiceController(serviceInstaller1.ServiceName);
            sc.Start();
        }

        

    }
}

Hope this will help to resolve such issue.


ASP.Net: Html Text at End of Downloaded File

I am having this issue a few days ago which is quite strange for me since I am new to development in ASP.Net and I have shifted from Windows Application Development in .Net.

Issue:
The issue is when you save a file from any webpage then some html text gets appended with the file which some times makes the file corrupt.

The code which I am using in order to save the file is shown below:

FileStream fStream = new FileStream("C://1.pdf", FileMode.Open, FileAccess.Read);
long FileSize = fStream.Length;

byte[] Buffer = new byte[(int)FileSize];
fStream.Read(Buffer, 0, (int)FileSize);
fStream.Close();

Response.Buffer = true;
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename=Output.pdf");
Response.BinaryWrite(Buffer);
Response.Flush();

Solution:
The solution is really simple which I got from google search.

The working code is shown below:

FileStream fStream = new FileStream("C://1.pdf", FileMode.Open, FileAccess.Read);
long FileSize = fStream.Length;

byte[] Buffer = new byte[(int)FileSize];
fStream.Read(Buffer, 0, (int)FileSize);
fStream.Close();

Response.Buffer = true;
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename=Output.pdf");
Response.BinaryWrite(Buffer);
Response.End();

The only issue is with the Response.Flush() line which I use often when working as a Desktop developer. But with web its not the case. So we have to call Response.End() and should not call Response.Flush().

Hope many will get benefit from this.

Saturday, January 26, 2013

CSS: Comments

All comments begin with a forward slash and asterisk (/*), and end with the
asterisk followed by the forward slash (*/). This is a very simple and easy to remember method
that you may prefer to use in more complicated or important styles.


Example:
/* Default styling for paragraphs */
p {
color: #F00;
font-size: 12px;
}
/* Make all top-level headings gray and 16px high */
h1 {
color: #333;
font-size: 16px;
}


Another method preferred by many designers further highlights the rule by adding a dashed line
with the comment a great way of carving up the style sheet and making it more visually
manageable.

Example:
/* Default styling for paragraphs
-------------------------------------------------------- */
p {
color: #F00;
font-size: 12px;
}

Friday, January 25, 2013

CSS: Defining a Style

CSS syntax is made up of the following entities:
  1. Selector (the element or tag you wish to control)
  2. Property
  3. Value

Example:
Below I am going to show an example in order to illustrate the style better.

body{
padding: 10px;
}

body - Selector
padding - Property
10px - Value

Always place a semicolon at the end of a property.

Hope you have got a better idea of the entities involved in CSS style.

 

Book: Beginning CSS Web Development


Few days ago I came accross this nice book on CSS which I found very much useful and I have learned a lot from it. Although I am a software devleoper myself but I am not a designer but I always feel lack of good designing capabilities and abilities in me. Although I tried a lot to learn how to design a website but I was not able to do so. The main reason is that I have not found any useful resource which will help me right from the beginning to advance level. But this book helped me a lot and now feel I have better understanding of CSS then before.

I want to share the basic topics which are covered in this book. Table of contents section is shown below. Hope you will got a better idea of what the book covers and if you want to read this book then you can pick it up.

Table of Contents:

PART 1 ■ ■ ■ Get to Know CSS
■CHAPTER 1 Getting Started . . . . . . . . . . .  . . . . . . . . . . . . . . . . . 3
■CHAPTER 2 Core Concepts of CSS . . . . . . . . .. . . . . . . . . . . . . . . . . 17
■CHAPTER 3 CSS Building Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . 39
■CHAPTER 4 Text . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . 55
■CHAPTER 5 Color, Backgrounds, and Images . . . .. . . . . . . . . . . . . . . . . 79
■CHAPTER 6 Lists . . . . . . . . . . . . . . . .  . . . . . . . . . . . . . . . . 103
■CHAPTER 7 Links . . . . . . . . . . . . . . . .  . . . . . . . . . . . . . . . . 129
■CHAPTER 8 Tables and Definition Lists . . . . .  . . . . . . . . . . . . . . . . 145
■CHAPTER 9 Forms . . . . . . . . . . . . . . . .  . . . . . . . . . . . . . . . . 167

PART 2 ■ ■ ■ Logical Layouts
■CHAPTER 10 Layout Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
■CHAPTER 11 Classic Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
■CHAPTER 12 Layout Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . 275
■CHAPTER 13 The Journey from Layout to Template . . . . . . . . . . . . . . . . . 291
■CHAPTER 14 Usability and Accessibility Enhancements .  . . . . . . . . . . . . . 315
■CHAPTER 15 Tips, Tricks, and Troubles . . . . . . . . .. . . . . . . . . . . . . 329
■CHAPTER 16 Case Study: The Dead Goods . . . . . . . . .. . . . . . . . . . . . . 347
■APPENDIX CSS Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . 387