Click here to Skip to main content
15,917,455 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Extra level of security need to be added using a SMS service(One Time Password two-factor authentication implementation Pin
bharat32119-Feb-15 2:38
bharat32119-Feb-15 2:38 
SuggestionRe: Extra level of security need to be added using a SMS service(One Time Password two-factor authentication implementation Pin
ZurdoDev19-Feb-15 2:42
professionalZurdoDev19-Feb-15 2:42 
QuestionLocalization - Unable to use any Actions from Pages in Navigation Bar if Arabic language is set Pin
RajeeshMenoth18-Feb-15 17:52
professionalRajeeshMenoth18-Feb-15 17:52 
AnswerRe: Localization - Unable to use any Actions from Pages in Navigation Bar if Arabic language is set Pin
Richard MacCutchan18-Feb-15 22:08
mveRichard MacCutchan18-Feb-15 22:08 
GeneralRe: Localization - Unable to use any Actions from Pages in Navigation Bar if Arabic language is set Pin
RajeeshMenoth18-Feb-15 22:28
professionalRajeeshMenoth18-Feb-15 22:28 
GeneralRe: Localization - Unable to use any Actions from Pages in Navigation Bar if Arabic language is set Pin
Richard MacCutchan18-Feb-15 22:37
mveRichard MacCutchan18-Feb-15 22:37 
GeneralRe: Localization - Unable to use any Actions from Pages in Navigation Bar if Arabic language is set Pin
RajeeshMenoth18-Feb-15 22:51
professionalRajeeshMenoth18-Feb-15 22:51 
GeneralRe: Localization - Unable to use any Actions from Pages in Navigation Bar if Arabic language is set Pin
Richard MacCutchan18-Feb-15 22:56
mveRichard MacCutchan18-Feb-15 22:56 
GeneralRe: Localization - Unable to use any Actions from Pages in Navigation Bar if Arabic language is set Pin
RajeeshMenoth18-Feb-15 23:02
professionalRajeeshMenoth18-Feb-15 23:02 
Rant[REPOST] Localization - Unable to use any Actions from Pages in Navigation Bar if Arabic language is set Pin
Richard Deeming19-Feb-15 2:25
mveRichard Deeming19-Feb-15 2:25 
QuestionHow to pass JavaScript variable to another page? Pin
samflex18-Feb-15 16:04
samflex18-Feb-15 16:04 
AnswerRe: How to pass JavaScript variable to another page? Pin
F-ES Sitecore18-Feb-15 23:40
professionalF-ES Sitecore18-Feb-15 23:40 
AnswerRe: How to pass JavaScript variable to another page? Pin
Member 1143449224-Feb-15 0:10
Member 1143449224-Feb-15 0:10 
QuestionMVC 5 Newbie Question - Plugins, Packages? Pin
jkirkerx18-Feb-15 6:45
professionaljkirkerx18-Feb-15 6:45 
Answer[GOT IT] You can modify the Simple Membership Pin
jkirkerx19-Feb-15 11:05
professionaljkirkerx19-Feb-15 11:05 
GeneralRegsiter User, it works but not sure if it's done right for MVC Pin
jkirkerx19-Feb-15 13:32
professionaljkirkerx19-Feb-15 13:32 
Not sure if I did this right, but I had to get the Register working.
So I modified the ActionResult register
[HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    int userID = WebSecurity.GetUserId(model.UserName);
                    bool s = WebSecurityExtender.UpdateUserAndAccount(userID, model.Name, model.CompanyName, model.EmailAddress);

                    WebSecurity.Login(model.UserName, model.Password);
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }

And wrote sort of an extender in App_Code
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;


namespace WebMatrix.WebData
{
    public class WebSecurityExtender
    {

        public static bool UpdateUserAndAccount(int userID, string name, string companyName, string emailAddress)
        {
            bool success = false;
            string connStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            SqlConnection conn = new SqlConnection(connStr);

            string query =
            "UPDATE " +
            " UserProfile " +
            "SET " +
            "  Name = @Name " +
            " ,CompanyName = @CompanyName " +
            " ,EmailAddress = @EmailAddress " +
            " WHERE UserID = @UserID ";

            SqlCommand cmd = new SqlCommand(query, conn);

            cmd.Parameters.Add(new SqlParameter("@UserID", userID));
            cmd.Parameters.Add(new SqlParameter("@Name", name));
            cmd.Parameters.Add(new SqlParameter("@CompanyName", companyName));
            cmd.Parameters.Add(new SqlParameter("@EmailAddress", emailAddress));     

            try
            {
                conn.Open();
                cmd.BeginExecuteNonQuery();                                

            }
            finally
            {
                conn.Close();

            }

            return success;
        }
    }
}


This is my first time working with MVC and C-Sharpe, and I know I could of done better in the database call, but I really had nothing to go on here. I need to add the catch as well.
QuestionWeb api works on localhost, but not on deployement server Pin
Member 1092967518-Feb-15 5:40
Member 1092967518-Feb-15 5:40 
QuestionUsing SQL Server CONTEXT_INFO feature in ASP.Net + Enterprise Library (v5 & above) Pin
Member 317000018-Feb-15 1:54
Member 317000018-Feb-15 1:54 
QuestionMVC 5, creating a download exe file link Pin
jkirkerx16-Feb-15 11:01
professionaljkirkerx16-Feb-15 11:01 
AnswerRe: MVC 5, creating a download exe file link Pin
Richard Deeming16-Feb-15 11:22
mveRichard Deeming16-Feb-15 11:22 
GeneralOh that's pretty slick Pin
jkirkerx16-Feb-15 11:40
professionaljkirkerx16-Feb-15 11:40 
GeneralRe: Oh that's pretty slick Pin
Richard Deeming16-Feb-15 12:06
mveRichard Deeming16-Feb-15 12:06 
GeneralRe: Oh that's pretty slick Pin
jkirkerx16-Feb-15 12:56
professionaljkirkerx16-Feb-15 12:56 
GeneralRe: Oh that's pretty slick Pin
Richard Deeming17-Feb-15 3:12
mveRichard Deeming17-Feb-15 3:12 
GeneralRe: Oh that's pretty slick Pin
jkirkerx17-Feb-15 8:01
professionaljkirkerx17-Feb-15 8:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.