ASP.NET MVC Identity User id to int - c#

I'm using ASP.NET Core with full .NET Framework and Identity and trying to change the user id type to int. I followed these steps (https://medium.com/#goodealsnow/asp-net-core-identity-3-0-6018fc151b4#.1uxf4m1s8) and it generates right tables and columns to the DB. I get this error when running the code (locally with Visual Studio 2015) and have no idea what to do:
System.Exception: de95f9a1-0d40-4922-a19f-0f300a69955c is not a valid
value for Int32. ---> System.FormatException: Input string was not in
a correct format.
It tries to open the start page but fails before anything is displayed.
It seems to me that some part of the code still tries to use wrong data type for the id but I can't pinpoint what. I have my own SQL database running locally and everything was working fine until I tried to change user id to int.

Perhaps there was Identity data of an old logged user in the cookies. I had the same problem and my solution was to delete all cookies from the site and refresh the page.

I still don't know what was wrong but I just re-cloned the repo to an earlier state and remade the necessary changes as described in the linked article. Now it works. Must've made a mistake somewhere. Thanks for the help.

Related

ASP.NET IIS Application 500 Internal Server Error

I have a very weird problem.
I have a development environment where I develop a ASP.NET MVC Application, in this environment everything works. Especially in the Application there is a certain AJAX call which calls on a controller and passes data, the controller just needs to update the database with the passed information.Everything works!.
However I hop onto the server with everything setup just as development environment(database,connection strings all that). An everything works fine, login functions as well as other database saving functions and controller actions seems to work fine. Except for ONE controller that return a 500 Internal Server Error.
I asked around and everyone wants to see the logs.
In the event viewer there are no logs pertaining to this 500 Internal Server Error.
IIS logs however did provide something,but the information does not give specifics on what is causing the 500 Internal Server Error.
I know what a 500 Internal Server Error is and I know its a generic error for a variety of problems, however after looking at the logs I cannot figure out why this specific controller action is giving a 500 error when it is live on the production server BUT no problems when doing it in the development environment-very weird.
Browser Console
IIS Normal Logs
IIS Failed Request Tracing on 500
I had similar problem 2 weeks ago and also had posted about it in stackoverflow [asp.net web api: only during sql connection - HTTP 500 Error occurs : Local host is currently unable to handle request.
After hours of looking into the issue, it was figured out as a stored procedure missing in database.
Not sure whether it will help you with the problem, but hope it can give you some lead to resolve the problem.
Following #A.Roussos's advice to use Visual Studio debugging on the PRODUCTION SERVER (might seem obvious for me it wan't haha), I got some information.
My problem is that before I save data to the database I parse a string to double using the parse function.
Example
double a = Double.Parse(mystring);
The problem however is apparently the parse function is reliant on your regional settings(CultureInfo).
So I just added the following information to the code
double a = Double.Parse(mystring,System.Globalization.CultureInfo.InvariantCulture);
Something to note is that my application didn't crash when I got the 500 Internal Server Error, I didn't have a clue as to what could cause it.After using Visual Studio I got sufficient information to use and google and figure this thing out.
What killed me was that the application(or the one specific controller action in the application) worked perfectly on the development environment but not on the production environment, something like that has never happened to me and I am glad I got this learning experience.
Can you make sure that the URL which you are hitting doesn't has any whitespace in it?
Have the web.Config set to the custom errors mode as off. You should be able to see the full errors and any additional details associated with these.
Many times there are missing aspects in the environment that causes these errors.
It seems that the error is generated by a private method being called in the controller's action method but the error itself is getting eaten (empty catch) or just throw, causing an application failure. Check if the exception handler is present and logging the details somehow.

Web Site Administration Tool

I am trying to follow a tutorial on creating a log in system and adding users in asp.net and i cant seem to work out how to use the apparently outdfated or expired Web Site Administration Tool. is there a new equivalent tool i can use or is there some way to get it to work as i cant seem to get it working using the command prompt.
I have tried entering this into the command prompt which works fine in order to rune iisexpress:
"C:\Program Files\IIS Express\iisexpress.exe" /path:c:\windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles /vpath:"/asp.netwebadminfiles" /port:8089 /clr:4.0 /ntlm
I then enter the following into my browser:
http://localhost:8089/asp.netwebadminfiles/default.aspx?applicationPhysicalPath=[Exact_Project_Path]\&applicationUrl=/
Where the project path is set to my project path but get the following error:
System.ArgumentException: The parameter 'PhysicalDirectory' is invalid. Parameter name: PhysicalDirectory at System.Web.Configuration.VirtualDirectoryMapping.set_PhysicalDirectory(String value) at System.Web.Configuration.VirtualDirectoryMapping..ctor(String physicalDirectory, Boolean isAppRoot) at System.Web.Administration.WebAdminPage.OpenWebConfiguration(String path, String appPhysPath, Boolean getWebConfigForSubDir) at System.Web.Administration.WebAdminPage.VerifyAppValid()
This to me seems to be that the path i enter is invalid but i have tried every different entry surrouding my solution.
Is there a new or better answer to creating a log in system with asp without all this fuss?
Very new to all this so please take it easy.
Take a look through https://www.asp.net/identity, and in particular the Introduction to ASP.NET Identity post, which gives an overview of the older ASP.NET Membership and the newer ASP.NET Identity. Identity is supposed to be a lot easier to integrate into your app.

Can I Generate a Password Rest Token in mvc 3?

I have an MVC 3 application, in which I am using actionMailer to send out emails (to the C drive for now) for Password reset etc.
The problem is I can send the e-mail and password reset no problem however there is nothing to stop the user from using that same email over and over again.
So I believe I need to send a token with the e-mail.
I've being trying to use...
var token = WebSecurity.GeneratePasswordResetToken(email);
I get following error...
You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.
UPDATE: Basically I'm looking for the steps involved in doing the above for an MVC 3 application!
I have no webpages tables in my database and would prefer not to have to add such tables now.
I have searched around the web and keep getting answers related to MVC 4, which as far as I can understand as built-in facility for the above.
I have webMatrix.WebData in place in my references folder, and have set "CopyToLocal = true".
If anyone as any advice can you please be as detailed as possible in your suggestions, also I can post up whatever additional code needed. Please keep in mind this is MVC 3 application.

Can't GET my application's app page (100)

My application has 3 pages associated with it. Here are their id's :
151500351683665 (Community page)
143448712494935 (Community page)
563925353640654 (Application page)
Using the facebook C# SDK, I'm trying to execute GET on those pages using the following url format :
graph.facebook.com/{pageId}
http://graph.facebook.com/563925353640654 -> Error
http://graph.facebook.com/143448712494935 -> Ok
http://graph.facebook.com/151500351683665 -> Ok
I'm successful when it comes to the community pages, however I'm getting a Unsupported GET request (100) when trying to access the Application page in this manner. I'm not sure what's going on this started to occur recently, the whole thing worked without passing any access tokens as I thought that this was public information :/
Any ideas?
Note: Until lately I was able make the forementioned GET requests without any access tokens - since I believe I was accessing public information. Right only unable to access a single page.
Copying the answer from this SO thread
This error occures due to several problems in the permissions of your page
1. Go to edit page->manage permission
Check Age restrictions: 13+
2. Go to basic information -> Start Type:: set to launched

ASP.NET MVC Configuration Manager error

The WSAT throws the following irrespective of the project or the connection type,
An error was encountered. Please
return to the previous page and try
again.
Even on a brand new ASP.NET MVC 2 website where user authentication and registration work through the default account controller without a quibble, the WSAT fails to run.
Things I've tried,
Tried to open it in IE.
Tried to use it with MySQL to setup
user authorization, role and profile
management. This was the goal which
is starting to seem more and more
like an uphill battle.
Tried it with a brand new ASP.NET
MVC 2 application.
Help would be greatly appreciated.
Found it. Apparently the configuration manager will not work if the directory path to the solution contains invalid characters, in my case it was a space.
Should be documented somewhere, this was a good waste of four hours..

Categories