5

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();
}
4
  • Your email provider is most likely filtering off your link, the answers below should work. Commented Jun 14, 2013 at 10:14
  • can you tell me more? Commented Jun 14, 2013 at 10:16
  • In Aspnet Mvc you can redirect as the 2 answers below have pointed out. The key bit of information you said in your question is that the link IN YOUR EMAIL is not working, this makes me think the link is being filtered/blocked from your mail client or mail server, somehow. Commented Jun 14, 2013 at 10:23
  • possible duplicate of How can I redirect to a URL? Commented Jun 17, 2013 at 7:23

3 Answers 3

10

Try this

string link = "http://www.google.com";
return Redirect(link);
Sign up to request clarification or add additional context in comments.

Comments

9

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.

3 Comments

Does it show the view? Then your Any() is not working correctly. It doesn't really make much sense to me anyway. Getting all entries, then comparing the first entry against all of them?
Try to debug your application and make sure if the line is actually hit.
what @HenkMollema said. If it shows the view, it's not getting into the IF. Simple as that
1

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.