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 3942600
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:40:58+00:00 2026-05-20T00:40:58+00:00

The following code works fine under Cassini, but not at all under IIS. I

  • 0

The following code works fine under Cassini, but not at all under IIS. I get file not found, and am unable to get files on a remote share, or locally when I tested C:\test.pdf (to test IIS permissions)

The intent of this application is to make a HTTP proxy that will allow files to be retrieved through a secure URL. The security code has been omitted from this sample. I’m just focusing on file access in this plain-vanilla sample.

I’ve made sure that the

  1. Application pool (Process Model Identity) is running a Domain Admin account
  2. Website Physical Path Credentials are running under the same admin account
  3. The admin account has both Batch and Run as a Service rights in the local policy.

I access the WCF service using the following URL

http://localhost:1651/services/GetFile.svc/get?swt=\\remoteserver\share\file.pdf

[ServiceContract(SessionMode = SessionMode.NotAllowed)]
public interface IGetFile
{
    [OperationContract]
    [WebGet(UriTemplate = "/get?swt={filename}", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
    Stream Get(string filename); 
}


 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class GetFile : IGetFile
{
    bool debug = true;

    public Stream Get(string filename )
    {
        //this will cause the file dialog to show the file name instead of "get" 
        WebOperationContext.Current.OutgoingResponse.Headers.Add( "Content-disposition", string.Format("inline; filename={0}", filename));
        WebOperationContext.Current.OutgoingResponse.ContentType = "application/octect-stream";

        FileStream fs1= null;

        //WindowsIdentity winId = new WindowsIdentity("aamankow@nfp.com");
        //using (winId.Impersonate())
        {
            try
            {
                fs1 = File.OpenRead(filename);
            }
            catch (FileNotFoundException e)
            {
                if (debug)
                throw;
                else
                return null;
            }
            catch (IOException e)
            {
                if (debug)
                throw;
                else
                // message: Either a required impersonation level was not provided, or the provided impersonation level is invalid.
                return null;
            }
        }

        return fs1;
  • 1 1 Answer
  • 3 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-05-20T00:40:58+00:00Added an answer on May 20, 2026 at 12:40 am

    The code above doesn’t work on version 3.5… just 4.0

    Changing the app pool to 4.0 fixed the issue, and allowed me to read from any UNC

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

Sidebar

Related Questions

The following code works fine on Linux but throws an exception on OS X
The following code works fine in firefox but as with many other things, I
The following code works fine in most browsers but it won't work in Internet
In chrome and safari, the following code works fine. in firefox , all platforms,
This code fails to compile using g++ 4.2.1 but works fine under vc++ v8.
The following code works fine: person = {:a=>:A, :b=>:B, :c=>:C} berson = {:a=>:A1, :b=>:B1,
The following code works fine for Visual C++ 2008. However, when comes to Visual
The following code works fine #define open { #define close } #include<stdio.h> #define int
The following code works fine : std::map<int, int>& m = std::map<int, int>(); int i
The following code works fine. class A { private: int _value; public: class AProxy

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.