Wednesday, 11 September 2013

MVC log in is not working

MVC log in is not working

I have a MVC3 application, n my log in module works fine when I run the
solution from VS. But when I added it as a site in my IIS(ver 6) The log
in is not working. I wrote to a txt file to see whether log in fails, but
log in is successful. But it does not let me to go to the home page it
directs me back to log in page itself. please help.
[HttpPost]
public ActionResult Login(LoginModel model, string returnUrl) {
string lines = "UserName:" + model.Username + " Pwd:" +
model.Password + " IsValid:" + ModelState.IsValid + "\n";
System.IO.File.WriteAllText(@"E:\Nirushan.txt", lines);
if (!ModelState.IsValid) {
ModelState.AddModelError("",
GetLocalResource("Message.InvalidLogin"));
return View();
}
var authenticationResult =
_authenticationService.TryAuthenticateDirectLogin(model.Username,
model.Password);
using (System.IO.StreamWriter file = new
System.IO.StreamWriter(@"E:\Nirushan.txt", true))
{
file.WriteLine();
//Status is success
file.WriteLine("Status:" +
authenticationResult.AuthenticationStatus);
bool st =
AuthenticationTicketService.SetAuthenticationTicket(authenticationResult.AuthenticatedUser.Id);
// st is true
file.WriteLine("TicketService:" + st);
}
if (authenticationResult.AuthenticationStatus ==
AuthenticationStatus.RegeneratedForgottenPasswordExpired)
{
ModelState.AddModelError("",
GetLocalResource("Message.RegeneratedForgottenPasswordExpired"));
return View();
}
if (authenticationResult.AuthenticationStatus ==
AuthenticationStatus.UserIsLockedOut) {
ModelState.AddModelError("",
GetLocalResource("Message.UserIsLockedOut"));
return View();
}
if (authenticationResult.AuthenticationStatus ==
AuthenticationStatus.DirectLoginNotAllowed) {
ModelState.AddModelError("",
GetLocalResource("Message.DirectLoginNotAllowed"));
return View();
}
if (authenticationResult.AuthenticationStatus !=
AuthenticationStatus.Success) {
ModelState.AddModelError("",
GetLocalResource("Message.LoginFailed"));
return View();
}
if (authenticationResult.AuthenticatedUser.PasswordChange)
return RedirectToAction("ChangePassword", new {
returnUrl,
model.Username
});
if
(AuthenticationTicketService.SetAuthenticationTicket(authenticationResult.AuthenticatedUser.Id)
== false) {
ModelState.AddModelError("",
GetLocalResource("Message.MissingSessionInfo"));
return View();
}
return Redirect(returnUrl ?? Url.Action("Index", "Home"));
}

C++ constructor arguments

C++ constructor arguments

Bozo(const char * fname, const char * lname); // constructor prototype
In this case, you would use it to initialize new objects as follows:
Bozo bozetta = bozo("Bozetta", "Biggens"); // primary form
Bozo fufu("Fufu", "O'Dweeb"); // short form
Bozo *pc = new Bozo("Popo", "Le Peu"); // dynamic object
I just have a few questions regarding this. First is that, why is const
needed before char? or why is it there?. Also, why is it declaring as a
pointer?
Second, is there any difference between the "primary form" and the "short
form?"
Third question is that in Java, I used string variables for the formal
parameters, but in C++ it's in char? I thought char can only contain a
single alphabet, and it's not a char array. Could I do this with string
instead?

How to test standard output string in other java file in Java?

How to test standard output string in other java file in Java?

So, in brief:
I have a method that is void, and prints stuff to standard output.
I have a second file that tests the output of functions against what it
should be and returns true if they all pass.
I have a makefile that checks the output of the test file to make sure
that all the tests passed.
My problem is that I don't know how to compare the void method's printed
output against what it should be in the test file. I was told to modify
the make file, but I don't know how. My other tests for methods with
return types look something like this:
private static boolean testNumFunc() {
if (MainFile.numFunc(300) == /*proper int output*/) {
return true;
}
return false;
}
How would I test a void function this way by modifying the makefile?

How is string#size implementated?

How is string#size implementated?

I did:
cout << sizeof(string) << endl;
is 8 on my 64bit machine which is the same as sizeof(char*) so I am
assuming the string class stores only the char*. Then how is the size
function implemented? Is it using strlen (since it is not store the actual
size or the pointer to the ending byte)?
But on this page: http://en.cppreference.com/w/cpp/string/basic_string/size
It shows the size function have a complexity of constant, so I am
confused. This page: Why is sizeof(string) == 32? tells me his string size
is larger...
I am using GCC 4.7.1 on Fedora 64 bit.

Pack a PrimeFace Dialog

Pack a PrimeFace Dialog

In Swing, you can call pack() which will make the frame that is displaying
contents shrink to the size of its contents.
Here is the JavaDoc for it: pack()
Causes this Window to be sized to fit the preferred size and layouts of
its subcomponents. If the window and/or its owner are not yet displayable,
both are made displayable before calculating the preferred size. The
Window will be validated after the preferredSize is calculated.
Is there a corresponding way to do this in a PrimeFaces dialog. Namely,
can I make a dialog shrink to fit its contents?

symfony2 slow performance due to the firewall

symfony2 slow performance due to the firewall

I have a problem with symfony2 (2.3.4), especially with the firewall. It
takes ages to complete the request and here is the debug screenshot.
I have also googled for solutions, but neither the change of the mysql
hostname to "127.0.0.1", nor the other hints have helped.
My settings: symfony2 (2.3.4), PHP 5.4.19, MySQL 5.1.66, Debian 6.0.7.

google api custom Infobox not maintain the same position of the marker in street view

google api custom Infobox not maintain the same position of the marker in
street view

We are using the custom infobox provided by the google api and when we go
to the street view then infobox position not changed according to marker
position in street view as they display in the actual map marker position.
Can anyone tell me how to set the customize infobox position according to
the marker position in the street view.
Regards, Vipul Singhal