0

I've worked out all the problems with the WEB API implementation in Umbraco (Token & Member creation in an http post), the problem I'm having here is this final macro, I've created to drop in an Umbraco page, it will not collect the token and email from the querystring. I keep getting a System.Data.SqlClient.SqlException (expects the parameter '@token', which was not supplied) Am I not able to grab a querystring in Umbraco, or more specifically an Umbraco macro?

namespace ****.SSO
{
    public partial class ****SSOMacro : System.Web.UI.UserControl,
        umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
    {
        static Token token = new Token();
        static string connStr = ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString;

        protected void Page_Load(object sender, EventArgs e)
        {                
try{
                **string tmpToken = Request.QueryString["token"];
                string tmpEmail = Request.QueryString["email"];

                //Check If Token Still Exists
                using (SqlConnection myConnection = new SqlConnection(connStr))
                {
                    myConnection.Open();
                    SqlCommand command = new SqlCommand("SELECT * FROM [DBTokenTable] WHERE tokens = @token and email = @email and valid = 'true'", myConnection);
                    command.Parameters.AddWithValue("@token", tmpToken);
                    command.Parameters.AddWithValue("@email", tmpEmail);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            token = new Token { token = reader["Tokens"].ToString(), email = reader["Email"].ToString(), valid = reader["Valid"].ToString() };
                        }
                    }
                    myConnection.Close();
                }**

            }
            catch (Exception ex)
            {
                string error = ex.ToString();

                //Log Any Form Cookies Out
                FormsAuthentication.SignOut();
                RawrLabel.Text = error;
                //Response.Redirect(HttpUtility.UrlEncode("https://google.com/#q=" + error));
            }
        }


        private string _umbval;
        public object value
        {
            get { return _umbval; }
            set { _umbval = value.ToString(); }
        }
Erik
  • 43
  • 1
  • 9
  • Also I'm sending a URL like this: http://localhost:9134/ssotest.aspx?token=b62a1691-83a5-4fc6-a405-bb8bad7bbbf5&email=guy%40company.com – Erik Jul 16 '14 at 18:55

1 Answers1

0

I was adding my macro onto a template page with Razor, so MVC didn't recognize the web forms Request.Querystring["value"] method. Instead just add the macro directly onto a content page with a Richtext editor.

Erik
  • 43
  • 1
  • 9