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

  • SEARCH
  • Home
  • 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 8614969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:15:17+00:00 2026-06-12T05:15:17+00:00

We currently use the code below to download files from a network server to

  • 0

We currently use the code below to download files from a network server to the client in an old ASP.net page.

We have re-written the app in MVC3 and would like to upgrade this functionality. I have seen several posts that claim you can access the file from the network share by writing the following lines in web.config

<authentication mode="Windows"/>
<identity impersonate="true" userName="" password="" />

However, we are currently using Forms authentication mode to logon to the site. Would that interfere with the login functionality?

Here’s our download code.

Partial Class DownloadFile2
   Inherits System.Web.UI.Page

   Private BufferSize As Integer = 32 * 1024

   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      Dim path As String = Request.Params("File")
      path = "\\speedy\wanfiles\" + path.Substring(3)
      Dim file As System.IO.FileInfo = New System.IO.FileInfo(path)
      Dim Buffer(BufferSize) As Byte
      Dim SizeWritten, fileindex As Integer
      Response.Clear()

      Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name)
      Response.AddHeader("Content-Length", file.Length.ToString)

      Response.ContentType = "application/octet-type"
      Response.Flush()

      fileindex = 0
      Do
         // not sure about this GM.AlasData code below
         SizeWritten = GM.AlasData.ReadFileBlock(file.FullName, Buffer, fileindex, BufferSize) 
         Response.OutputStream.Write(Buffer, 0, SizeWritten)
         Response.Flush()
         If SizeWritten < BufferSize Then
            Exit Do
         Else
            fileindex = fileindex + SizeWritten
         End If
      Loop

      Response.End()


   End Sub

End Class

I found this code to do downloads using MVC3 but cannot access the file because it is considered a local file.

public FileResult Download(string FilePath)
{
    if (FilePath != null)
    {
        string path = FilePath;
        string contentType;
        // files are stored on network server named speedy
        path = string.Concat(@"\\speedy\files\", HttpUtility.UrlDecode(path));
        System.IO.FileInfo file = new System.IO.FileInfo(path);
        Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(file.Extension.ToLower());
        if (rk != null && rk.GetValue("Content Type") != null)
        {
            contentType = rk.GetValue("Content Type").ToString();
        }
        else
        {
            contentType = "application/octet-type";
        }

        //Parameters to file are
        //1. The File Path on the File Server
        //2. The content type MIME type
        //3. The parameter for the file save by the browser
        return File(file.FullName, contentType, file.Name);

    }
    else
    {
        return null;
    }
}

What needs to be done to fix this where we can perform this functionality?

  • 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-12T05:15:18+00:00Added an answer on June 12, 2026 at 5:15 am

    http://www.codeproject.com/Articles/4051/Windows-Impersonation-using-C

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently use the following code to position a div directly below an input
I am currently accessing a secure web server using the code below (which works
I currently have an existing code in bash that greps a keyword from a
Below is the part code I currently use to write to a file, Try
I write a script to force download mp3 files from a site. The code
Currently I use the following code to retrieve the IP address of the local
This is the code I currently use: <% Uri MyUrl = Request.UrlReferrer; if( MyUrl
Using the following code, we got the error 'Object is currently in use elsewhere'
I am currently adapted a code to my website's use but now I would
I have the following SQL design issue. The code below might look a little

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.