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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:52:29+00:00 2026-05-12T14:52:29+00:00

Can I set up HTML/Email Templates in C# on ASP.NET? This question was asked

  • 0

Can I set up HTML/Email Templates in C# on ASP.NET?

This question was asked and answered by SkippyFire and others…I have a follow up question. I like to keep things very simple, as a novice developer.

If I am not correct, Skippyfire said you could send the complete aspx page using this code:

StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htmlTW = new HtmlTextWriter(sw);
this.Render(htmlTW);

Then just use net.mail to send on Page.Load event. This is very confusing to me. I can use this to render controls to an email.Body and send but I can not use this to load an entire page in anyway I have discovered.

Using Net.mail…

How would I send the page above? I tried to put nothing on the page but some text and send it using it’s own page load event… I can not figure out any other way to send it from another page or button… (how would you do this? Wouldn’t you have to somehow load the URL into an object?)… anyway I tried to do it from Page Load itself as Skippyfire describes in an old post and get this error from Visual studio IDE:

A page can have only one server-side Form tag.

Any help would be appreciated.

CS

  • 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-12T14:52:29+00:00Added an answer on May 12, 2026 at 2:52 pm

    There is another way to do this… You can host the ASP.Net runtime in your application. It’s not major difficult either, this is “sort-of” what you need to do…

    1. First step is to create a remote-able object that will be used to communicate with the domain. It’s only needed method is one to return the output of a page:

      internal class RemoteAspDomain : MarshalByRefObject
      {
          public string ProcessRequest(string page, string query)
          {
              using (StringWriter sw = new StringWriter())
              {
                  SimpleWorkerRequest work = new SimpleWorkerRequest(page, query, sw);
                  HttpRuntime.ProcessRequest(work);
                  return sw.ToString();
              }
          }
      }
      
    2. Then when your ready to create/work with ASP.Net you setup the environment like:

      public static string RunAspPage(string rootDirectory, string page, string query)
      {
          RemoteAspDomain host;
          try
          {
              host = (RemoteAspDomain)ApplicationHost.CreateApplicationHost(typeof(RemoteAspDomain), "/", rootDirectory);
              return host.ProcessRequest(page, query);
          }
          finally
          {
              ApplicationManager.GetApplicationManager().ShutdownAll();
              System.Web.Hosting.HostingEnvironment.InitiateShutdown();
              host = null;
          }
      }
      
    3. Now you should be able to use it with the following:

      string response = RunAspPage("C:\\MyWebAppRoot\\", "/default.aspx", "asdf=123&xyz=123");
      

    Obviously, you don’t want to do this for every request as it takes time to perform the startup-shutdown operations. Simply refactor the RunAspPage to be an IDisposable class that destroys the environment on dispose instead of using the finally block.

    Update, BTW if Your already running in an ASP.Net session, there are far easier ways to do this. See HttpServerUtility.Execute Method (String, TextWriter)

    Please Note: The above code was copy/pasted and simplified from a working copy, I think I got everything you need but my actual implementation is much more complicated. If you have any trouble there are several real-world examples of these API on the internet.

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

Sidebar

Related Questions

Hy, In my ASP.NET MVC application in the aspx page I set <% Html.EnableClientValidation();
How can I set the background color of an HTML element using css in
how can I set embed parameters for html wrapper using Flex Builder ? For
I can set data in JTable constructor, and then user can change this data
How can I have this other box display at the bottom of the first
I want to make email templates in Zend Framework. For example, <html> <body> Dear
I am creating a report on an asp.net web page using an html table
I have an HTML5 form set up like so: <form id=contact-form action=php/email.php> <fieldset> <ul
I'm trying to send an email message using the .NET MailMessage class which can
If i have a ViewModel like this: public class SignupViewModel { [Required] [DisplayName(Email:)] public

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.