Showing posts with label Asp.Net MVC. Show all posts
Showing posts with label Asp.Net MVC. Show all posts

How to upload large files using MVC




 This is the third post of file upload in mvc ,first was Upload a File In MVC , second was  Upload Multiple File In MVC  and this is Third "Big File Upload In MVC". In ASP.NET default size of uploading a file is 4MB if  we want to upload a file bigger than 4MB size than we need to have some changes in Web.config file. Lets start

Step1:- For creating a file upload application follow this link Upload a File In MVC  or  Upload Multiple File In MVC    

UploadFile.Cshtml

@{
    ViewBag.Title = "UploadFile";
}
<h2>UploadFile</h2>
 
@using (Html.BeginForm("UploadFile""FileUploading"FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div>
        <br />
        <input type="file" id="files" name="files" multiple>
        <input type="submit" value="Upload" />
        @ViewBag.Message
    </div>
}

Upload multiple file in mvc

 

# Upload multiple file in mvc

Note:- Fundamentals of uploading multiple file is same as uploading single file, so just follow previous post of file upload (click on mvc menu at website and find the link of file upload in mvc ). we need just two changes in file upload application ,first is in method now we use foreach loop in basic code and second change will be in view,use multiple attribute of textbox.   

Replace the code of .Upload a File in MVC application with these two file respectively


UploadFile.Cshtml


@{
    ViewBag.Title = "UploadFile";
}
<h2>UploadFile</h2>
 
@using (Html.BeginForm("UploadFile", "FileUploading", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div>
        <br />
        <input type="file" id="files" name="files" multiple>
        <input type="submit" value="Upload" />
        @ViewBag.Message
    </div>
}

how to upload a file in mvc



Step1:- Create a New Project in Visual Studio from File menu bar or Prss Ctrl+Shift+N

and Give a name it FileUpload. After Creating project create a folder with name 'UploadedFiles' in your project file.





Crud operation in mvc with dbfirst and repository

 


Crud in MVC with DbFirst and Repository Pattern:-

C:-Create

R:-Read

U:-Update

D:-Delete

Repository Pattern:-  The repository patterns are intended to create an abstraction layer between the data access layer and the business logic layer of an application.


crud operation in asp.net mvc with codefirst approach

 1.Simple CRUD Application with CodeFirst Approach in MVC.

First Step:- Create a Project  in Visual Studio with Name "CrudOperation", Select MVC from project template.Your project is ready.

Second Step:- Add following two Classes in your Model Folder


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

 

1.

namespace CrudOperation.Models

{

    public class Student

    {

        public int Id { getset; }

        public string Name { getset; }

        public int Age { getset; }

        public string City { getset; }

    }

}

crud operation in mvc with db first approach




This is the example of basic Crud Operation in Asp.NET MVC with Database First Approach/DbFirst Approach of EntityFramework.In next blog i will show you how to use Stored Procedure in DbFirst Approach.In this example i am using visual Studio 2015 and Sql-Server 2014 on Windows7 operating System.So Lets Start:-



First Step:-Create a Project with name DbFirstDemo in your Visual Studio.

Second Step:-Open your Sql-Server and Create a table named with Student.
Third Step:-Click on Model Folder then Click on Add then Click on New Item now below window will show then click on Add button at bottom right.