Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7936623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:16:16+00:00 2026-06-03T22:16:16+00:00

Here is my code: This is the function being called by fiddler using: http://localhost:3334/Service/Login/?json={‘username’:’cara’,’password’:’password’}

  • 0

Here is my code:
This is the function being called by fiddler using:

http://localhost:3334/Service/Login/?json={'username':'cara','password':'password'}

public ActionResult Login(JObject JSON)
{
    var response = JsonResponse.OKResponse();
    var username = JSON["username"].ToString();
    var password = JSON["password"].ToString();

    var helper = new MemberHelper();

    //goes into here and never returns
    if (helper.ValidateUser(username, password))
    {
        MongoCollection<User> users = db.GetCollection<User>();
        var usr = users.FindAll().FirstOrDefault(u => u.UserName.Equals(username));
        response.data.Add(usr);
    }
    else
    {
        return Json(JsonResponse.ErrorResponse("Invalid username or password provided!"), JsonRequestBehavior.AllowGet);
    }

    return Json(response, JsonRequestBehavior.AllowGet);
}

And the validateUser method within MemberHelper:

public override bool ValidateUser(string username, string password)
{
    var hash = Encoding.ASCII.GetBytes(password);
    var provider = new SHA256CryptoServiceProvider();
    for (int i = 0; i < 1024; i++) // 1024 round SHA256 is decent
         hash = provider.ComputeHash(hash);
    var pass = Convert.ToBase64String(hash);


    MongoCollection<User> users = db.GetCollection<User>();

    //***The following statement is where the program just stops***    
    var usr = users.FindAll().FirstOrDefault(u => u.UserName.Equals(username) && u.Password.Equals(pass));
   ...
}

And getCollection….

public MongoCollection<T> GetCollection<T>(string name = null)
{
    string collectionName = name; 
    if (collectionName == null) { 
        collectionName = typeof(T).Name; 
    }
    return Database.GetCollection<T>(collectionName); 
}

I really don’t know what is going wrong. I am new to linq so I am not sure if there is some golden rule that I am breaking. Please help! Let me know if there is anything else I need to add.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:16:18+00:00Added an answer on June 3, 2026 at 10:16 pm

    The problem was indeed within the method GetCollection<>() once I replaced it with the following code, it worked just fine:

    public MongoCollection<T> GetCollection<T>(string name = null)
            {
                string collectionName = name;
                if (collectionName == null)
                    collectionName = typeof(T).Name;
                if (Database.CollectionExists(collectionName) == false)
                    Database.CreateCollection(collectionName);
                return Database.GetCollection<T>(collectionName);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In here, http://jsfiddle.net/sjKgF/78/ JS CODE $('.display_box').hover(function (){ $(this).attr('class', 'display_box current') }, function (){ $(this).attr('class',
Here in this code: $('#doneItem').click(function(){ $(this).each(function(index){ var item = 'personal' + index; alert(item); localStorage.removeItem('personal'
I have this code here: var Person = (function() { var name; var PersonConstructor
This my jquery function, function getRecordspage(curPage, pagSize) { // code here $(.pager).pagination(strarr[1], { callback:
Here is some code: var class = function(elem,div){ this.elem= elem; this.div = div; this.init
Here is my code: $(#myCheckBox).click(function () { if (!$(this).is(':checked')) { $('#txtDateFrom').attr('readonly', true); $('#txtDateTo').attr('readonly', true);
here is my code: $(a).live('click', function(){ history.pushState({}, '', this.href); popstate(this.href); $(#loadpage).css(display, block); return false;
Here is my spaggeti code $(#table_exams tbody tr).click(function () { window.location.hash=# +$(this).attr(exam_ID); window.location.href=/medilab/prototypes/exams/edit?examId= +
Code is not running on .click when I have this: $(.cancel).click(function() { alert(got here);
Here is my code : This is my handleMessage Function : public void handleMessage(Message

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.