Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:03:50+00:00 2026-06-10T23:03:50+00:00

So I upload the file and add the GUID to the database, and on

  • 0

So I upload the file and add the GUID to the database, and on my index view page, I want to display that file with the original file name in one column and GUID in the next column, Any suggestion?

class define as

public Guid ID { get; set; }
    public string FileName { get; set; }

the index controller

     public ViewResult Index()
    {

        return View(uploadedfileRepository.AllIncluding(UploadedFile => UploadedFile.TimeEntrys));
    }

and the view

 @foreach (var item in Model)
{
    <tr>
        <td>
            @item.ID
        </td>
        <td>
           @item.FileName
        </td>
}

So I save the file into my uploadfile database context and try to display that in index view with my origianl file name and guid next to it.

The way I save my file

UploadedFileRepository newUploadedFileRepository = new UploadedFileRepository();
    private string _uploadsFolder = HostingEnvironment.MapPath("~/App_Data/Files/");

    public Guid SaveUploadedFile(HttpPostedFileBase fileBase)
    {
        var identifier = Guid.NewGuid();
        fileBase.SaveAs(_uploadsFolder + identifier + suffix(fileBase.FileName));
var file = new UploadedFile { FileName = _uploadsFolder + identifier + suffix(fileBase.FileName), ID = Guid.NewGuid() };
        _repository.UploadedFiles.Add(file);
        return identifier;

    }
    static string suffix(string filename)
    {
        string[] names = filename.Split('.');

        return "." + names[1].ToString();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:03:52+00:00Added an answer on June 10, 2026 at 11:03 pm
    @model MyWebApplicationNameSpace.Models.MyModel
    
    <table>
      <tr>
        <td>@Model.ID</td>
        <td>@Model.FileName</td>
      </tr>
    </table>
    

    Instead of returning a Guid, why not return the UploadedFile Type.

    public UploadedFile SaveUploadedFile(HttpPostedFileBase fileBase) {
    
        ...
        return file;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add some functionality in admin that allows me to upload file
I have a page where the user can dynamically add file upload boxes. Adding
I'm working on a form and want to add a file upload to the
I want to add file uploader on front product view of product. here are
I need to add a file upload function to an ASP.NET website and would
I'm trying to extend a form and add an upload file field from within
I add asp.net file upload control as follows: <asp:FileUpload ID=filesFileUpload runat=server /> <asp:RegularExpressionValidator ID=RegularExpressionValidator3
Inside a grails application, I need to upload a file under web-app/js, add a
I want to upload file to a host by using WebClient class. I also
I want to upload videos with next way: I just upload file to server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.