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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:05:02+00:00 2026-06-08T19:05:02+00:00

I have a simple redirect in my code: public ActionResult Redirect() { return Redirect(http://url.com);

  • 0

I have a simple redirect in my code:

public ActionResult Redirect()
{
    return Redirect("http://url.com");
}

I noticed that the response includes the following html in the response body:

HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: http://url.com
Server: Microsoft-IIS/7.0
Date: Tue, 24 Jul 2012 18:53:52 GMT
Content-Length: 198

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="http://url.com">here</a>.</h2>
</body></html>

Is there a way to remove the html from the response body? I would like the Content-Length to be zero by not having anything in the response body.

  • 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-08T19:05:03+00:00Added an answer on June 8, 2026 at 7:05 pm

    You can do this by implementing your own ActionResult instead of using the built in RedirectResult, which will send that HTML.

    However, you should not need to – the user should never see that markup, but it is provided for, mostly, legacy issues. Also be aware some browsers can be set to not follow redirects – not having the body there would then render the result pretty useless.

    If you still want a Redirect without body, this result class would do it:

    public sealed class RedirectResultNoBody : ActionResult
    {
        private readonly string location;
        public RedirectResultNoBody(string location) 
        {
            this.location = location;
        }
        public override void ExecuteResult(ControllerContext context) 
        {
            var response = context.HttpContext.Response;
            response.StatusCode = 302;
            response.RedirectLocation = location;
            response.End();
        }
    }
    

    Which would then be used like this:

    public ActionResult Redirect()
    {
        return new RedirectResultNoBody("http://url.com");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my simple ubercart payment gateway module to redirect
I have a simple MVC2 app that doesn't seem to Redirect correctly. The code
I have a simple question about url or domain redirect. I was looking through
We all know that wordpress have simple .htaccess code like below RewriteEngine on RewriteBase
I have a simple subscribe form at : http://thepanamainsider.com/sanblas/index9.php The form doesn't work, it
I have a simple servlet named Autentica that is responsible to get de code
I have a simple code that manages to successfully query an SQLite Database and
I have a simple htaccess redirect to send visitors from website.com/promotions to website.com/go/promotions. If
I have a very simple .htaccess file set up to redirect a 404 to
I have a bash script that simply calls different calls and redirect stdout and

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.