Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to redirect to another url

Tags:

c#

asp.net-mvc

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();
}
like image 706
novian kristianto Avatar asked Dec 04 '22 10:12

novian kristianto


1 Answers

Try this

string link = "http://www.google.com";
return Redirect(link);
like image 119
Jayram Avatar answered Dec 25 '22 09:12

Jayram