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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:21:28+00:00 2026-05-26T15:21:28+00:00

I’ve been studying WCF and been refactoring my ASMX webservice solution (multiple projects) slowly

  • 0

I’ve been studying WCF and been refactoring my ASMX webservice solution (multiple projects) slowly according to “best practices” I’ve found and I’ve come upon some design/architecture issues where I feel a great need to pause and seek advice.

SUMMARY: How to use HttpContext in a WCF service that does NOT use ASP.Net MVC and “routes”?

DETAILS:
Better performance is a primary goal for this re-write and I’ve read that NetTcpBinding is best for that, and so I think I need to avoid:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

and need to avoid:

serviceHostingEnvironment aspNetCompatibilityEnabled="true"

Thus, the webservice refactored for WCF needs to avoid ASP.NET dependencies such as HttpContext, Session, etc. I don’t use Session at all but one webmethod (UploadFile) currently uses HttpContext as in these snippets:

[WebMethod(Description = "Upload a file with metadata properties packed in a delimited string")]
    public string UploadFile(string trimURL
                , byte[] incomingArray
                , string fileName
                , string RecordTypeName
                , string metaDataString)
    {
    string pathFileInfo; // declared here in a "bare block" so it is in scope for the finally block too
        try
        {
            pathFileInfo = ByteArrayToFile(fileName, incomingArray);
            FileInfo fi = new FileInfo(pathFileInfo);
            if (fi.Exists)
            {

and here is where HttpContext is used:

        public string ByteArrayToFile(string _FileName, byte[] _ByteArray)
    {
        string fullName = HttpContext.Current.Server.MapPath(@".\UploadWorkArea\") + _FileName;
        using (FileStream _FileStream = new FileStream(fullName
                    , FileMode.Create
                    , FileAccess.Write))
        {
            _FileStream.Write(_ByteArray, 0, _ByteArray.Length);
            _FileStream.Close();
            return fullName;
        }
    }

Therefore, I found this advice here: http://msdn.microsoft.com/en-us/library/aa702682.aspx:

“Within an AppDomain, features implemented by the HTTP runtime apply to ASP.NET content but not to WCF. Many HTTP-specific features of the ASP.NET application platform do not apply to WCF Services hosted inside of an AppDomain that contains ASP.NET content. Examples of these features include the following:

  • HttpContext: Current is always null when accessed from within a WCF service. Use RequestContext instead.

and just below that:

“These restrictions apply only to WCF services hosted in IIS application. The behavior of ASP.NET content is not affected by the presence of WCF.
WCF applications that require functionality traditionally provided by the HTTP pipeline should consider using the WCF equivalents, which are host and transport independent:

OperationContext instead of HttpContext.”

Finally, I have added this namespace:

using System.Web.Routing;

.. in order to resolve this issue with this:

public RequestContext(
HttpContextBase httpContext,
RouteData routeData

)

And I have arrived at the point where I’m feeling very uncertain about proceeding further. I’ve read a little bit about ASP.NET MVC and it’s use of “routing” but I am not really there – I am just thinking about rebuilding this so it could use a faster binding for performance.

Hopefully, my question is clear and I have not rambled too much for you to give me some advice on this.

  • 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-05-26T15:21:29+00:00Added an answer on May 26, 2026 at 3:21 pm

    refer to the second answer at How to get working path of a wcf application?

    string mappedPath = string.Format(@"{0}\UploadWorkArea\", System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath);
    

    Did I miss something or is that all you need?

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has

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.