Error. An error occurred while processing your request - c#

Fairly simple question about connection strings using an ASP.Net MVC web application with a SQL server Database.
I created a Web application which uses a database, using the default templates for an MVC 5 application using Visual studio 2014.
I am moving my application over to a IIS and sql server express database (2014) and I see that the database my application uses is a localDB (has a .mdf extension) what I need to know is how to attach it to my SQL Server Express database. (The development Machine and the Server are separate machines)
I have attached it to the server and have a login "IIS APPPOOL\DefaultAppPool" for my IIS to be able to use the server. Here I have granted the login read and write permission to the database "aspnet-owinTest-20140519094353" and my connection string in IIS is
Server=KEVIN-PC\SQLEXPRESS;Database=aspnet-owinTest-20140519094353;Integrated Security=true
The default connection string when building my application is:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-owinTest-20140519094353.mdf;Initial Catalog=aspnet-owinTest-20140519094353;Integrated Security=True" providerName="System.Data.SqlClient" />
If anyone can please give me a hand with this. My application simply throws an error
Error.
An error occurred while processing your request.
This is the default MVC error.
Also are there any ways where I can see what happened? As in a log of sorts, I checked in the IIS log and there did not seem to be any information that would help me. Would it be better for me to just have a login that used a Username/Password rather than using Windows Authentication?

I believe I found what I was looking for:
How to deploy ASP.NET MVC 4 application using localDB to local IIS on Windows 7?
This did the trick, though probably not a good idea for production server.
I guess one would have to do some type of restore on the SQL server from the .mdf.
All one has to do is publish their files, drop them in the wwwroot folder (along with the app_data folder containing your database and logs) and set the pool to local and you should be set.

If you are quite new to Visual Studio and facing this error, the very first thing I would suggest to check is INCLUDE all the files from the project. If there are some dependent folders or files which are left as excluded, this very error message is thrown back to browser.
To do this, first click on the icon of "Show All Files" and check for any of the expected files which you created/added but didn't include in the project. If you find one, then right click and include it.
If there is any quicker way to identify/avoid any such excluded files/folders issues, then please share below in comments.

Related

Umbraco 8 shows install screen after deploying on GoDaddy server

I have developed site using Umbraco 8 and uSkinned theme. I am able to run in my local development environment as well as local IIS. but when I deploy it to GoDaddy it shows me install screen.
I followed below are the steps.
Visual Studio Publish to folder.
Using above published folder I hosted site to my local IIS(it works on IIS)
I have created backup of database
Restored backup to GoDaddy SQL Server. I checked after restoreing, tables and data is there on GoDaddy SQL Server(I used LinqPad).
I used publish output created on step 1 and updated connection string and uploaded to GoDaddy.
When I browse site it shows me install screen.
Why it shows me install screen even if it has data in database as well as same set of file as IIS local? What I am missing.
Thanks for help
Edit
I get below logs
{"#t":"2021-03-24T11:50:03.7387476Z","#mt":"{EndMessage} ({Duration}ms) [Timing {TimingId}]","EndMessage":"Booted.","Duration":1592,"TimingId":"6f43df2","SourceContext":"Umbraco.Core.Runtime.CoreRuntime","ProcessId":1700,"ProcessName":"w3wp","ThreadId":29,"AppDomainId":3,"AppDomainAppId":"LMW3SVC8ROOT","MachineName":"S107-180-73-24","Log4NetLevel":"INFO ","HttpRequestNumber":1,"HttpRequestId":"75319e5f-ad35-4c7b-9aa2-fe04a05c9007"}
{"#t":"2021-03-24T11:50:04.1450357Z","#mt":"New url {Url} detected, re-discovering application url.","Url":"http://yourmodern.skinfogroup.com/umbraco","SourceContext":"Umbraco.Core.Sync.ApplicationUrlHelper","ProcessId":1700,"ProcessName":"w3wp","ThreadId":16,"AppDomainId":3,"AppDomainAppId":"LMW3SVC8ROOT","MachineName":"S107-180-73-24","Log4NetLevel":"INFO ","HttpRequestNumber":2,"HttpRequestId":"7f3c5e24-22d0-4cc8-940d-13b6e8622a9f"}
{"#t":"2021-03-24T11:50:04.1450357Z","#mt":"ApplicationUrl: {UmbracoAppUrl} (UmbracoModule request)","UmbracoAppUrl":"http://yourmodern.skinfogroup.com/umbraco","SourceContext":"Umbraco.Core.Sync.ApplicationUrlHelper","ProcessId":1700,"ProcessName":"w3wp","ThreadId":16,"AppDomainId":3,"AppDomainAppId":"LMW3SVC8ROOT","MachineName":"S107-180-73-24","Log4NetLevel":"INFO ","HttpRequestNumber":2,"HttpRequestId":"7f3c5e24-22d0-4cc8-940d-13b6e8622a9f"}
{"#t":"2021-03-24T11:50:04.5356961Z","#mt":"Umbraco must install or upgrade.","#l":"Warning","SourceContext":"Umbraco.Web.UmbracoModule","ProcessId":1700,"ProcessName":"w3wp","ThreadId":16,"AppDomainId":3,"AppDomainAppId":"LMW3SVC8ROOT","MachineName":"S107-180-73-24","Log4NetLevel":"WARN ","HttpRequestNumber":2,"HttpRequestId":"7f3c5e24-22d0-4cc8-940d-13b6e8622a9f"}
EDIT 2
I validated that connection string correct. I am able to connect to the database and execute queries. I have also validated that it has same no of tables and rows.
This Umbraco forum thread says it could be a permissions issue: https://our.umbraco.com/forum/using-umbraco-and-getting-started/102946-moving-umbraco-v8-to-new-server-fails-you-see-this-screen-because-your-umbraco-installation-did-not-complete-correctly#comment-322275 - specifically the part in there about
changed the permissions on the server (by creating a new sql server
user and login with the same rights)
Heres my debuggin tips:
Have you upgraded? Have you copied the DB into live, or, you using a fresh DB?
How are you doing your transforms? Perform a file compare between files using a tool like Beyond Compare
Delete contents of Add_Data
Install screen can be triggered if Umbraco.Core.ConfigurationStatus is not populated
See this for details:
https://www.jondjones.com/learn-umbraco-cms/umbraco-7-tutorials/umbraco-upgrading-guide/how-to-reinstall-umbraco/
There was issues with the server. I validated this by.
Hosting same website on other server(works)
Hosting website with default data on same server(does not works).
Edit
Rebuilding server did not fix the issue.

Deploy a webiste on IIS and reuse the automatically created DB from the project

I published my site on a web server and it works very well (at least to access it) but I would like to use the DB that was automatically created when I was in a development environment.
I initially checked 'Individual account' by creating the project, made some changes (creation of roles, fields in the ASPnetUser table, etc), did some stuff and then publish it and now I would like to recover the DB i had when i was working with Visual Studio on this app (the data inside does not matter to me).
When I published my site with Visual Studio 2017, I was asked to check the providerName and the context.
So I ticked both options leaving the basic information (System.data.SqlClient & connection string to my context (who's not the basic ApplicationDbContext)).
Then, browsing my site, I tried to connect to a login that existed in development on my machine but no way, I also tried to create a new account (thinking that this would regenerate a db) but no way either.
I looked on the internet but I found nothing, except for Microsoft but they use Azure, which does not interest me.
Could you guide me on the processes to follow (even just a link to a tutorial would be very useful)?
I still specify that the server is on Windows Server 16
The best solution for this, in my opinion, is to install a standalone MS SQL server on your machine and create the base of your project not on localdb, but on that server (you need just to change connection string in your Web.config to do it).

Database connection in windows azure

I have an N-Tier MVC4 project connected to an SQL server database.
The MVC4 project was created using the MVC internet application template in VS.
I'm trying to deploy this project to windows azure.
The website was added to azure with no problems the database was added with no problem as well.
When i browse to my website it's there but when i try to do actions related to the DB such as register/login/view a certain list i get the error:
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections."
my development connection string is:
<add name="CarRentalDataBaseEntities" connectionString="metadata=res://*/CarRentalDataBase.csdl|res://*/CarRentalDataBase.ssdl|res://*/CarRentalDataBase.msl;provider=System.Data.SqlClient;provider connection string="data source=CONSTANTINE-PC\SQLEXPRESS;initial catalog=CarRentalDataBase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
my production connection string is:
<add name="CarRentalDataBaseEntities" connectionString="metadata=res://*/CarRentalDataBase.csdl|res://*/CarRentalDataBase.ssdl|res://*/CarRentalDataBase.msl;provider=System.Data.SqlClient;provider connection string="Server=tcp:ptuwjgqh7p.database.windows.net,1433;Database=CarRentalDataBase;User ID=XXXX;Password=XXXX;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
when i run the project in VS it works fine with no problems, which means that remote connections allowed to the database.
Seems that there something wrong with the connection between the website and the database in azure but i dont know what.
please advise what can i check in order to find the problem.
Thank you.
EDIT:
I just created draft MVC website that has a connection to a database and it worked - There is a connection to the DB in azure.
The difference was that this website wasnt N-Tier designed meaning it didnt have a business logic project.
In my original website (the one that i still didnt manage to connect to a DB) there is a business logic project and the database edmx file is on that project.
The publish to azure that i did was to the MVC website project that has a reference to the business logic(which has the edmx DB file).
Any suggestions on the latest findings?
Thank you.
Eventually I found that in the publish menu, in Settings under databases, from some reason, the connection string did not match the connection string in AppConfig and Azure management portal all though I performed a Clean-Rebuild on the entire solution before publishing.. Anyway mystery solved after almost a year!
On the firewall section of the portal for that server have you turned on access to Azure Services?

Transfering ASP.Net Website Project From One Computer To Another

Ive been working on a project on my computer and i want to transfer it to my laptop. The project is an ASP.Net Website Project in C#. I'm using SQL Server 2012 to hold my database and the Asp.net user management tables in my database also.
What's the easiest way to do this, as i have backed up my database and copied the ASP.net website folder onto my laptop and changed data source, but I'm getting a few errors, especially on the asp.net configuration page it has also removed my roles due to the transferring.
If i understood you correct, what you need is to deploy the ASP.NET Membership Database to the new project location. There are set of tools and commands that you need to use.
You would need to construct a command-line like the following:
C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync
-source:dbfullsql=" [your connection string] "
-dest:dbfullsql="c:\temp\InsertIntoAspNetDB.sql
Again the exact path and command will depend on your local configuration.
You may get more detailed information from MSDN - How to: Deploy a Database With a Web Application Project

Database '...\DATABASE.MDF' cannot be upgraded because it is read-only or has read-only files

I wanna install an ASP.NET application on WIN XP SP3,
Thus I've installed IIS 5.1 , .Net Framework 3.5 SP1 and MSSQL 2008 R2 on my WinXP SP3.
Then, I copied my application folder to C:\Inetpub\wwwroot\
Next, I've created an application from my folder in IIS Manager and I set the permissions as the following image :
As you can see, I can't write and even read from the database and whenever I wanna write into the database I receive the above exception.
What's the wrong with it ?
P.S:
I'm using Win XP on VMware Workstation 7.1
The application is running in Win Vista x86 and Win7 x64 without any problems.
The application was written with .Net Framework 3.5 SP1
You must edit permissions, allowing "Network Service" to edit the MDF file.
Did you check your database file's property (readonly attribute), and ACL security permissions (permissions that are defined on the file level - not in the IIS management console) ?
I've found the solution.
I disabled the Windows Firewall and shared the folder with `Allow Users to change my files" , and now I can write and read from the database easily :-)
This was weird. It turned out part of my application was referencing one aspnetdb file in Sql Server and the other was trying to reference one locally created in the application.
My connection string was for this :
<add name="ApplicationServices"
connectionString="Data Source=localhost; Initial Catalog=aspnetdb; Integrated Security=True" providerName="System.Data.SqlClient" />
But the error was this
There was a failure using the default 'ProfileProvider'. Please make
sure it is configured correctly. Database
'C:\WEBSITES\XXXX.SILVERLIGHT\ADMIN\APP_DATA\ASPNETDB.MDF'
cannot be upgraded because it is read-only, has read-only files or the
user does not have permissions to modify some of the files. Make the
database or files writeable, and rerun recovery.
It took me a while to notice that this was under my application root, and not the Sql Server version that the main part of my application uses.
In my case I just renamed the locally created aspnetdb files and when I reran the pplication it just recreated them at their default sizes (10240kb and 504kb).
I'm not quite sure how this is happening, but i my case this was a sufficient fix.
I think maybe I wasn't using the profile provider explicitly so it was using default settings. The rest of the application was using the correct connection string.
You add Users group into the sercurity tab with Full Control

Categories

Resources