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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:38:00+00:00 2026-05-18T00:38:00+00:00

I need to dynamically instantiate a web application from a console application. By this

  • 0

I need to dynamically instantiate a web application from a console application. By this definition, I mean that my console application contains a web application that is not bound to IIS/XSP.

Currently, I create the web application into a temporary directory and copy some forged files into it. These are a special Global.asax that maps to my own implementation of HttpApplication to use in the web application (I need to do some initialization at app start), then I forge special .asmx files that map to my own skeleton classes and dynamic plugins

            foreach (IPlugin plugin in _target.Plugins)
            {
                WsdlSkeletonDefinition[] defs = plugin.GetWsdlSkeletons();
                if (defs != null)
                    foreach (WsdlSkeletonDefinition def in defs)
                    {
                        if (def.SkeletonType == null)
                            throw new LogbusException(string.Format("Plugin {0} declares empty skeleton type",
                                                                    plugin.Name));
                        if (def.SkeletonType.IsAssignableFrom(typeof(System.Web.Services.WebService)))
                            throw new LogbusException(
                                string.Format("Plugin {0} does not declare a valid WSDL skeleton type", plugin.Name));

                        string fname = def.UrlFileName;
                        if (fname.EndsWith(".asmx", false, CultureInfo.InvariantCulture))
                            fname = fname.Substring(0, fname.Length - 5);

                        if (!Regex.IsMatch(fname, @"^[a-zA-Z0-9_\.\-%]+$", RegexOptions.CultureInvariant))
                            throw new LogbusException(string.Format(
                                "Plugin {0} declares invalid WSDL endpoint: {1}",
                                plugin.Name, def.UrlFileName));

                        string wsDeclaration = string.Format(ASMX_TEMPLATE, def.SkeletonType.AssemblyQualifiedName);

                        using (
                            StreamWriter sw = new StreamWriter(File.Create(Path.Combine(_physicalPath, fname + ".asmx")),
                                                               Encoding.Default))
                            sw.Write(wsDeclaration);

                        //Copy skeleton asembly if needed
                        CopyAssemblyTo(def.SkeletonType.Assembly, bindir);
                        foreach (AssemblyName dependency in def.SkeletonType.Assembly.GetReferencedAssemblies())
                        {
                            try
                            {
                                CopyAssemblyTo(Assembly.Load(dependency), bindir);
                            }
                            //Possible broken dependency
                            catch { }
                        }
                    }
            }

My approach works, but I’m not so satisfied by it because I have to write lots of garbage into file system, even if I eventually delete it all.

I know I can control HTTP handlers via Web.config, but I don’t want to forge a Web.config for that. I would like to create a mapping such as I can remove the .asmx extension from web services’ URLs and still get them.

For example, one of the default scripts is "LogbusManagement.asmx", which must be hard-coded into client APIs and the .asmx prevents portability to other platforms such as PHP. I want to make "LogbusManagement.asmx" equivalent to "LogbusManagement" and any extension. For this, I might use an HttpHandlerFactory.

My straight question is,

like asked here by somebody else: is there a way to programmatically, possibly from Global.asax, to set IHttpHandlers or IHttpHandlerFactories for web applications?

Thank you

  • 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-18T00:38:01+00:00Added an answer on May 18, 2026 at 12:38 am

    This question was already answered in the stackoverflow:

    Any way to add HttpHandler programatically in .NET?

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

Sidebar

Related Questions

How do I dynamically reload the app.config in a .net Windows application? I need
I need to dynamically create a Video object in ActionScript 2 and add it
Possible Duplicate: Change CSS Dynamically I need to change the height of a div
I need to set the text within a DIV element dynamically. What is the
Need a function that takes a character as a parameter and returns true if
Need to an expression that returns only things with an I followed by either
need ask you about some help. I have web app running in Net 2.0.
Need a function like: function isGoogleURL(url) { ... } that returns true iff URL
I need to develop a file indexing application in python and wanted to know
This is beyond both making sense and my control. That being said here is

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.