简体   繁体   中英

how to redirect to another url

i make a simple application in asp.net mvc 4

i make a random link, and send the random link to email.. and when i click link in email, it will redirect to www.google.com

my problem is, if i click my link at my email, i'm not redirect to www.google.com

how i can solve my problem?

this my code

public ActionResult Index(alamatWeb alamatweb)
    {
    var encryptText = MyEncryptDecript.Library.lockIt.EnString("a");
    var clearText = MyEncryptDecript.Library.lockIt.DeString(encryptText);
    ViewBag.encrypt = encryptText;
    ViewBag.decrypt = clearText;
    PasswordRandom x = new PasswordRandom();
    string paswordacak ="http://localhost:4466/User?UserID="+ x.GeneratePassword();
    ViewBag.acak = paswordacak;

    alamatweb.link = paswordacak;
    alamatweb.referensi = "www.rajakamar.com";

    url.alamatWebs.Add(alamatweb);
    url.SaveChanges();

    var c = (from d in url.alamatWebs
             select d.link).First();

    var aar = new tampilModel { 
        link = c
    };

    new MailController().SampleEmail(aar).Deliver();
    return View();
}

public ActionResult User()
{
    var e = (from a in url.alamatWebs
             select a.link).ToList();

    var c = (from d in url.alamatWebs
             select d.link).First();

    if (e.Any(u => u == c))
    {
        return Redirect("www.google.com");
    }
    return View();
}

Use

return Redirect("http://www.google.com");

RedirectToAction is only supposed to redirect to another action in any other or the same controller you are currently in, depending on the used overload.

Try this

string link = "http://www.google.com";
return Redirect(link);

Check your firewall and email provider. They may be blocking Google. And then try with:

return Redirect("http://www.google.com");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM