Illegal characters in path. AccountController.cs - asp.net

I'm using ASP.NET MVC default account system and recently when I try to login or register I'm getting this error:
Server Error in '/' Application.
Illegal characters in path.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Illegal characters in
path.
Source Error:
Line 46: if (ModelState.IsValid)
Line 47: {
Line 48: var user = await UserManager.FindAsync(model.UserName, model.Password);
Line 49: if (user != null)
Line 50: {
Source File:
c:\Users\u1152923\Desktop\newsWebApplication\newsWebApplication\Controllers\AccountController.cs Line: 48
No changes have been made to the AccountController.cs recently, so I dont understand where the problem has come from.
It's possible a change to web.config could have caused the error. The full web.config is below:
http://pastebin.com/iMviLJGS
Any help is appreciated.

I have managed to fix it! The problem infact comes from the IdentityModel.cs
Make sure the below is referencing the correct connection!
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection")
{
}
}
Thanks all for your help.

Related

got this error : An unknown server-side error occurred while processing the command. Original error: Cannot read property 'replace' of undefined

Entered the desired capabilities from appium desktop and started the seesion and got this error : "An unknown server-side error occurred while processing the command. Original error: Cannot read property 'replace' of undefined"
On SetUp should be ("platformName", "iOS")
public void StartDriver()
{
DesiredCapabilities cap = new DesiredCapabilities();
cap.SetCapability("platformName", "iOS");
cap.SetCapability("deviceName", "iPhone Xr");
cap.SetCapability("automationName", "XCUITest");
cap.SetCapability("app","YourApp.app");
cap.SetCapability("autoAcceptAlerts", true);
driver = new IOSDriver<IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap, TimeSpan.FromSeconds(300));
Assert.IsNotNull(driver.Context);
}
It would be better if you could provide more information about your error, but guessing from the error text, this is caused when you do not provide platformName capability.

Asp.Net Bundle - How to raise exception when minification fails

I'm using Asp.Net MVC 5 and the bundling and minification system from System.Web.Optimization 1.1.0.0:
bundles.Add(new ScriptBundle("~/angularLibraries").Include(
......
));
and then to render the Bundle:
#Scripts.Render("~/angularLibraries")
From time to time I manually check the state of my bundles by opening the corresponding url in the browser, and sometimes I find them with errors. Example:
/* Minification failed. Returning unminified contents.
(262,145-152): run-time error JS1019: Can't have 'break' outside of loop: break a
(40,297-304): run-time error JS1019: Can't have 'break' outside of loop: break a
*/
Because the bundling mechanism returns the unminified contents when the minification fails, I'm unaware of the error until I manually open that bundle in a browser.
How can I setup the Bundling system to raise an exception when minification fails so I can immediately be aware of the error?
Found a solution. I have created a custom class that derives from ScriptBundle and overrides the method ApplyTransforms:
public class CustomScriptBundle : ScriptBundle
{
public CustomScriptBundle(string virtualPath)
: base(virtualPath)
{
}
public CustomScriptBundle(string virtualPath, string cdnPath)
: base(virtualPath, cdnPath)
{
}
public override BundleResponse ApplyTransforms(BundleContext context, string bundleContent, IEnumerable<BundleFile> bundleFiles)
{
BundleResponse bundleResponse = base.ApplyTransforms(context, bundleContent, bundleFiles);
if (bundleResponse.Content.StartsWith("/* Minification failed. Returning unminified contents."))
ExceptionManager.LogMessage("Minification failed for following bundle: " + context.BundleVirtualPath);
return bundleResponse;
}
}
I ended up logging a message (an receiving an email notification from Elmah) and not throwing an exception because I have minification enabled by default only on production, and the app will continue working ok anyway.
If you throw an exception, you'll see it like this:
This solution is also applicable for StyleBundle.

Hosting my MVC 5 entity framework code first project ! MULTIPLE ERRORS

I'm trying to host my ASP.NET MVC 5 Entity Framework code first project (the project is running perfectly fine on my machine with local db connection strings) on go daddy. I've been getting a few errors and I was able to correct them up until now.
Now I'm getting this error:
CREATE DATABASE permission denied in database 'master'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: CREATE DATABASE permission denied in database 'master'.
I've removed the trust level option in my web.config file because it was creating problems with CAS trust level in the asp.net net parameters of godaddy. My CAS trust level in go daddy is set to full.
My connection strings:
<add name="DefaultConnection"
connectionString="Data Source=ipadress;AttachDbFilename=|DataDirectory|\aspnet-aspProjetFinal-20141211061340.mdf;Initial Catalog=aspnet-aspProjetFinal-20141211061340;Integrated Security=false;User Id=myuser; Password=mypassword;"
providerName="System.Data.SqlClient" />
<add name="monModel"
connectionString="data source=ipadress;initial catalog=GestionClientsContext;Trusted_Connection=True;Integrated Security=false;MultipleActiveResultSets=True;App=EntityFramework;User Id=myuser; Password=mypassword;"
providerName="System.Data.SqlClient" />
I've tried a few things, for example, this:
http://forums.asp.net/t/1742970.aspx?CREATE+DATABASE+permission+denied+in+database+master+
But I'm not sure if I need to delete some lines after adding said line at the top of the code.
My global.asax.cs file:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
Database.SetInitializer<GestionClientsContext>(null);
Database.SetInitializer(new InitialisationGestionClients());
GestionClientsContext testing = new GestionClientsContext();
testing.Database.Initialize(true);
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
//throw new Exception(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
}
I clearly need some guidance, I've already spent a lot of hours just trying to get it online ! Let me know what you think ! Thanks !
What you asked for Dan:
public class InitialisationGestionClients : System.Data.Entity.CreateDatabaseIfNotExists<GestionClientsContext>
{
protected override void Seed(GestionClientsContext context)
{
base.Seed(context);
var lesClients = new List<Clients>
{
new Clients{nom="Finch", prenom="Paul",dateInscription=DateTime.Parse("2014-01-10"),adresse="911 De la Commune", email="test#hotmail.com", solde=0,commentaires="Juste un test"}
};
lesClients.ForEach(s => context.Clients.Add(s));
context.SaveChanges();
var lesFacures = new List<Factures>
{
new Factures{motif="Programmes janvier 2014", montant=25,dateFacturation=DateTime.Parse("2014-01-10"),statusPaid=false, ClientsId=1}
};
lesFacures.ForEach(s => context.Factures.Add(s));
context.SaveChanges();
var lesPaiements = new List<Paiements>
{
new Paiements{montant=25,datePaiements=DateTime.Parse("2014-02-10"), ClientsId=1}
};
lesPaiements.ForEach(s => context.Paiements.Add(s));
context.SaveChanges();
}
}
UPDATE: I've gotten the site to "run" if I can use this word. I can now access the application online BUT as soon as I try to login or create a new user, using the MVC login feature, I get the following error:
CREATE DATABASE permission denied in database 'master'.
I already got that error before when the application was trying to load but I didn't get it since I change the trust level to FULL. I'm not sure I'm following this one ! I'm just trying to login why is he trying to create anything at all !

DomainContect is raising "Logon failure: unknown user name or bad password."

I have the following code inside my asp.net mvc web application to retrieve the Active directory user names:-
public List<DomainContext> GetADUsers(string term=null)
{
List<DomainContext> results = new List<DomainContext>();
using (var context = new PrincipalContext(ContextType.Domain, "v800047"))
using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
{
the above was working well on our development environment, but when i moved my code to the staging server and i changed the AdServerName accordingly , i am getting the following error :-
Description: An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error
and where it originated in the code.
Exception Details: System.DirectoryServices.DirectoryServicesCOMException:
Logon failure: unknown user name or bad password.

Generic Handler Jquery Post error

I am getting this error (at the bottom) when I try to run this code using a generic handler
Jquery Code
$.post("CheckUserName.ashx?username=Aaron902",
function (result) {
$('#username_availability_result').html('Name already exist!');
if (result == "exists") {
$('#username_availability_result').html('Name already exist!');
}
else {
$('#username_availability_result').html('Still available');
}
});
Handler Code
public void ProcessRequest(HttpContext context)
{
string user_name = context.Request.QueryString["username"];
string output = "here";
output = CheckUserNameAvailability(user_name);
context.Response.Write(output);
context.Response.End();
}
Server Error in '/' Application.
Parser Error Description: An error occurred during the parsing of a
resource required to service this request. Please review the
following specific parse error details and modify your source file
appropriately.
Parser Error Message: Could not create type 'Dating.CheckUserName'.
Source Error: Line 1: <%# WebHandler Language="C#"
CodeBehind="CheckUserName.ashx.cs" class="Dating.CheckUserName" %>
Source File: /CheckUserName.ashx Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.237
I found a fix to my issue although I am not sure why it works this way and not the original way. All I did was remove the code behind file and put all the code that was there into the ashx file instead of having it in the ashx.cs file.
Of course I removed the directive CodeBehind="CheckUserName.ashx.cs"

Resources