1

Hey all this is my code here:

View:
  -Email
    |-Email.cshtml

Email.cshtml:

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Email</title>
</head>
<body>
    <div> 
    </div>
</body>
</html>

And my controller (EmailController) looks like this:

namespace BOM2017.Controllers
{
    public class EmailController : Controller
    {
        [HttpGet]
        public ActionResult Email(string action, string id)
        {
            return View();
        }
    }
}

What I am trying to do is have a user click on a link inside an email and have it load up this page and take the parameters that the link is passing and pass them into the Email.cshtml page.

http://localhost/BOM2017/Email/Email?action=d&id=5124-48g56-dd59-fr8d

However, hitting that URL above seems to do nothing but load the page up. I put a break on the return View(); and it never hits it.

enter image description here

StealthRT
  • 10,108
  • 40
  • 183
  • 342
  • 1
    If your running from Visual Studio, looks like your missing your port: `http://localhost:XXXXXX/BOM2017/Email/Email?action=d&id=5124-48g56-dd59-fr8d` – mxmissile Nov 06 '17 at 15:07
  • **nothing but load the page up**. Which page is loading when you request that url ? – Shyju Nov 06 '17 at 15:09
  • @Shyju It's just a blank page. – StealthRT Nov 06 '17 at 15:10
  • maybe it can be about 'action parameter' see this https://stackoverflow.com/a/31749391/4293929 – Mustafa ASAN Nov 06 '17 at 15:13
  • May I know what is **action** ? Is it just a variable or you want the **action name** here, that you are passing with your URL. – Basanta Matia Nov 06 '17 at 15:24
  • Can u swap the order of your parameters. It will be like **(string id, string action)** and check once and let me know. – Basanta Matia Nov 06 '17 at 15:28
  • The **action** is either an "a" or "d". **A** for **Accept** and **D** for **Deny**. – StealthRT Nov 06 '17 at 15:32
  • Do you have a specific route that handle `BOM2017` part in the URL? If you're using a default routing then your url should look like: '~/Email/Email?action=d&id=5124‌​-48g56-dd59-fr8d' – Roman Koliada Nov 06 '17 at 15:37

1 Answers1

1

Ok looks like this has solved the issue:

View:
  -Email
    |-Index.cshtml

.

[HttpGet]
public ActionResult Index(string userAction, string id)
{
   ViewBag.returnedValue = "";

   if (userAction == "a")
   {

   } else if (userAction == "d")
   {

   }

   return View();
}

I needed to rename the Email to Index. And string action needed to be changed to something else since it seems action is a reserved name?

And therefore my link needed to be changed to:

 http://localhost/BOM2017/Email?userAction=d&id=5124-48g56-dd59-fr8d

After doing those 2 things it seems to be hitting my break point just fine with the needed 2 parameters.

StealthRT
  • 10,108
  • 40
  • 183
  • 342