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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:47:49+00:00 2026-06-04T10:47:49+00:00

I need my app to send a confirmation email to a user. I have

  • 0

I need my app to send a confirmation email to a user. I have used the following method to render the view as a string:

    public string RenderViewToString<T>(string viewPath, T model)
    {
        using (var writer = new StringWriter())
        {
            var view = new WebFormView(viewPath);
            var vdd = new ViewDataDictionary<T>(model);
            var viewCxt = new ViewContext(ControllerContext, view, vdd, new TempDataDictionary(), writer);
            viewCxt.View.Render(viewCxt, writer);
            return writer.ToString();
        }
    }

which I got from here. It works great, however my images aren’t being included. I’m using:

<img src="<%:Url.Content("~/Resource/confirmation-email/imageName.png") %>"

which is giving me

http://resource/confirmation-email/imageName.png

This works fine when viewing the page on the site, however the image links don’t work in the email.

I need it to give me me:

http://domain.com/application/resource/confirmation-email/imageName.png

I’ve also tried using:

VirtualPathUtility.ToAbsolute()
  • 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-04T10:47:50+00:00Added an answer on June 4, 2026 at 10:47 am

    This is what I used on a site recently:

    public static string ResolveServerUrl(string serverUrl, bool forceHttps = false, bool getVirtualPath = true)
    {
        if (getVirtualPath)
        serverUrl = VirtualPathUtility.ToAbsolute(serverUrl);
    
        if (serverUrl.IndexOf("://") > -1)
        return serverUrl;
    
        string newUrl = serverUrl;
        Uri originalUri = System.Web.HttpContext.Current.Request.Url;
        newUrl = (forceHttps ? "https" : originalUri.Scheme) + "://" + originalUri.Authority + newUrl;
        return newUrl;
    }
    

    I could then use it to generate Absolute urls by doing Core.ResolveServerUrl("~/Resource/confirmation-email/imageName.png"); (assuming you wrap the static function in a class named Core)

    HTH

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

Sidebar

Related Questions

I have this need to place my app in the share/send context menu so
I have a C++/MFC application I need to restructure. The app used to process
In my app I need to send a String[] titlephotos; to another Activity. I
In my app before I send a string off I need to work out
In my app I need to send SMS, so I use the following code
I just need to play a simple sound, I have app that send messages,
I need to send a Push notification message to all users of my app.
On a iPhone app, I need to send a jpg by mail with a
my app need to show user scrollable menu bar under tab bar like fox
Android Calendar App I need to be able to implement a view similar to

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.