MySQL .NET Connector 6.7.4 - asp.net

I'm am unable to use MySQL Connector 6.7.4 with my local asp.net provider, a security message is being shown saying that it doesn't have the GAC security accesss, anyone know if there's any chance (like in on web.config) to make it work ?
I know that my local web hosting provider (called locaweb) uses a medium trust environment and refuses to make any changes on their server (such as adding mysql latest version to their GAC). Old version of the connector, such as 6.2.2 are working fine.
I've read several articles in the internet (such as http://dev.mysql.com/doc/refman/5.1/en/connector-net-medium-trust.html) but it didn't make clear to me if the changes were in my application's web.config or in my hosting config (which they refuse).
Thanks,

Related

deploying asp.net core 2.1 web application on window hosting receiving 403

I have deployed my newly created web app developed in Asp.net core 2.1 on a windows based shared plesk hosting.
When i tried to browse the site, it give me this error
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
I have searched it on google but all the help is coming for .net framework not for the .net core framework. Existing solution has suggested me to put this code in web config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
but in .net core 2.1 there is no web.config in the project..
Bottom line issue is still there, don't know what to do.
First of all ensure that the your shared hosting provider support .NET Core hosting as it requires .NETCore Hosting Bundle installed and .NET CLR Version set to No Managed Code
Next publish your ASP.NET Core web app which will generate web.config file and then upload the published files on the server.
You may need to look at hosting's website or get in contact with them to determine whether they support .NET Core, at what runtime version and what needs to be done to have it set up for a website. They may need to do it manually and you may need to downgrade to their version.
The simplest way to handle this with shared hostings is to publish fresh template that works locally, copy it over to hosting (or use Web Deploy to do this directly from Visual Studio) and if it errors, write a ticket that your .NET Core site isn't working and it's up to them to install and set up everything that is necessary.
If they can't get it working, then you won't be able to either. Nothing else you can do, but to change hosting provider.
Literally just stumbled on this question after finding a resolution to the exact same problem.
My scenario is:
I was trying to move hosting providers - website already live, running from old host's webspace.
New host was a shared windows-based web hosting provider, running Plesk.
I was therefore trying to publish my .Net Core 2.0 project to my new host.
...and I kept getting a "403 - Forbidden Access" error.
Here's what I found, which I think might have been part of the problem that the OP faced.
Even though I had published the website to the remote server correctly, the 403 error kept coming until the new host's technical support pointed me to one of their knowledgebase posts, which exactly described my scenario and the issues I had, along with how to overcome them.
Essentially, I didn't have my domain name's DNS settings configured yet (as it was still in use, pointing to my previous hosting provider's webspace) and as such, the DNS are getting 'confused'.
The short-term workaround was to add a temporary entry to my hosts file on my PC, which directed the traffic for my website to the IP address of the NEW web hosting provider. (Once full go-live, these are deleted).
Something like this:
123.123.123.123 mywebsite.com
This allowed me (on my PC) to bypass the DNS settings on my domain name, and to reference the web content on the new web host's webspace, to continue setting-up and configuring the website, prior to full migration
Here's the link to their knowledgebase article, which I'd have never of thought of, until they mentioned it. (And then it made perfect sense!!)

ASP.NET Core Identity - Invalid Token (Linux)

I'm using the latest .NET Core (1.1) and EF Core to build my ASP.NET website and I also use ASP.NET Identity, and I have already published my website to Azure host and everything is working as expected there(including my Windows localhost). However now I'm switching to my own Linux(Centos 7) dedicated server with Apache, and I have the site working however I get "Invalid Token" messages when trying to reset password or confirm email.
I have checked other questions like this and solution was to encode/decode url which is sent via email, however I have did that already but it's not working still.
I also tried to copy the whole database from localhost to my server in case there was something with migrations on the Linux host, however that also did not help. All migrations are applied and other things that don't use Identity context also work.
After additional searching I have found that it might be problem with different machine keys on the host and that the security stamp is not in sync, but I don't see how could that affect me because I deploy a whole new version of my app to the server, and on localhost everything works as well on Azure hosting. Also this used to be the problem with ASP.NET MVC, not Core.
How can I even debug this issue? I have not seen anyone having this problem with the new EF Core and especially not on Linux host.
I deploy the site using the latest VS 17. I have set up Apache proxy as guided on the official .NET Core website: link
Dotnet core MVC application on default saves your Authentication tokens encrypted in a cookie.
The seed/key for this encryption/decryption of the data is based on your machine key, which is different on every machine.
If you ran multiple instances of your app (load balanced) this message/error will happen when your system tries to decrypt the session cookie, created on the other machine.
On the other hand if you still have cookie information in your browser and you start hosting the website on a different host ofcouse this new host wont be able to decrypt these already existing session cookies.
I Know this because i had the same problem. You can find the source-code of session here: https://github.com/aspnet/Session/tree/dev/src/Microsoft.AspNetCore.Session
I tried this when dotnet core was not yet released and i ended up using this blog. But probably now is very outdated.
I'd advice you advice you to use an external session store instead of using the cookie as data storage. read through their documentation on how to set that up: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/app-state

ASP.NET Core - Application not connecting to database after publishing

I created a simple ASP.Net Core application with user authentication (so all the Entity Framework has been preloaded into the web app template). It is connecting to my database with the connectionString that is located in my appsettings.json file, with "data source = {computerName}\\{serverName}" setup.
The database instance and Visual Studio are located on the same machine. This works fine in returning data to the web api while within development and debugging mode. When I publish it and try to go to the site from a domain name it does allow me to view the webpages that are not needing database connection but the rest that need data from the database returns pages like this:
Error.
An error occurred while processing your request.
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
Development environment should not be enabled in deployed
applications, as it can result in sensitive information from
exceptions being displayed to end users. For local debugging,
development environment can be enabled by setting the
ASPNETCORE_ENVIRONMENT environment variable to Development, and
restarting the application.
I have tried to change the Environment Variables for ASPNETCORE_ENVIRONMENT from Development to Production to no success.
I have tried adding appsettings.Production.json to publishOptions in my project.json file, even though there is no file appsettings.Production.json, and this did not help. dotnet publish
Adding the evironment variable in the web.config file did not work Deployment
I need help getting the published web api to connect to my SQL Server database from outside the development Visual Studio setup.
The last thing I can think of is that maybe I am incorrect in how I understand the connection string. If the web api uses the connection string to connect to the database from the server-side then it should work just fine like it does when in development calling to http://localhost:port# since it's all on the same machine. But, if the database string needs to be based on a client-side call then it would have to be with domain names and IP addresses.
Can someone tell me which one it is?
The only thing else that comes to mind is that there is something I am not doing, and need to do, inside of IIS Manager. I see connect string there as well but unsure what that is for our does since the connection string is inside the application. Also maybe I am suppose to give the app some kind of authorization to communicate with the database server even though they are on the same machine???
After much research, finally googling "how to deploy a web api in iis" I was able to learn from Host ASP.NET Web API in IIS using Visual Studio Publish that I needed to add the security entity BUILTIN\IIS_IUSRS. Then placing a mapping to my database tables and giving db_datareader (and possibly db_datawriter) for the database to the IUSER to allow access from my self hosted IIS web api. This from the above mentioned link with the part stating
Accessing Database under IIS APPPOOL\ASP.NET v4.0
As we are using ASP.NET v4.0 App Pool make sure IIS APPPOOL\ASP.NET v4.0 is added to your Database Server -> Security -> Logins.

Deploy ACCESS OleDb driver

I've tried to deploy a small website (ASP.NET) which is using an MS ACCESS 2010 db. Deploying the website on the server I get the following error:
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
Connectionstring used : Provider=Microsoft.ACE.OLEDB.12.0; Data Source=path-to-db
MS Office is not installed on the server and neither is the Access Database engine. The website is runnin in a shared hosting environment, so I am not able to install office on that server, so may I somehow deploy the provider by dll's?
Is it possible to deploy the drivers needed for ASP.Net to connect to the database without having to run an installation on the server. As this is in a shared hosting environment, I am not able to install anything. Only fileupload by ftp.
Open IIS, navigate to Application Pools, find the appPool for your website, right click, advanced settings, set "Enable 32-Bit Applications" to true.
Looking around, this has nothing to do with Office. If you're only using Access as the database, then you don't need to install it. Info here: http://www.mytechsupport.ca/forums/index.php?topic=11237.0
I found this StackOverflow thread with the same error you did so it sounds like it might be the same issue. Microsoft.ACE.OLEDB.12.0 provider is not registered
If its running windows then look through that thread and see if the 64-bit issue is the problem. I've had this same issue before and its apparently quite common. You may need to e-mail whoever for support on your server.
Is it running Linux? If it is running linux then the issue might be just an entire lack of the driver to connect to Access databases. If this is the case I would e-mail your support and ask them if they can install the proper drivers for you. Info here: http://nixcraft.com/databases-servers/11878-connect-microsoft-access-database-php-linux-server.html

Deployment Issues: Oracle + EF4 + Win Server 2008

I have an ASP.NET Web Forms app that I am building and running against .NET 4.0 on a Win7 local machine. (All is OK on local box.) My app is running EF4.1 against an Oracle DB, so I am using the Oracle EF data provider, which is still in Beta.
Right now, I can successfully deploy the app to my Win2008 Server target machine using Web Deploy from my local VS2010, but when I run the app on the target, I get the classic Unable to find the requested .Net Framework Data Provider error.
Here's my (unsuccessful) setup, as of now:
32-bit applications are enabled in the app pool (.NET 4.0) on the
Win2008 Server target.
Copy Local is set to true for the Oracle.DataAccess DLL in my local VS2010 solution.
Both of the Platform and Platform target settings are set to Any CPU in my local Build Configuration. (I have tried
different settings here without success.)
The Win2008 Server target does not have an Oracle.DataAccess DLL in
the GAC. (I thought that setting Copy Local on the Oracle DLL would
mean that I didn't need the GAC.)
EDIT: I have tried to GAC the Oracle.DataAccess DLL, but I get the same error that is discussed here. (I still have to investigate this.) Also, there is already another Oracle client on my target box, and installing the Oracle client that comes with the Oracle EF data provider seems to interfere with it. This cannot be allowed to happen.
Question 1: What combination of build configuration settings (on the local box) and IIS settings (on the target) do I need to select in order to be able to run my app on the 2008 Server?
Question 2: How can I get this to work without installing another Oracle client on my target server?
Thanks again for the help.
Update: All is working. See my answer below for a link to the full solution, as well as links to helpful information.
Since your server doesn't have Oracle.DataAccess in the GAC, that indicates that you haven't installed the Oracle client on that machine and are trying to make it work by deploying Oracle.DataAccess.dll as part of your app.
I'm not quite sure exactly what needs to be installed on the server. I usually just run the Oracle setup on the server to ensure that all the necessary Oracle files and settings get installed. If you do that, you don't need to deploy Oracle.DataAccess.dll along with your app, it will already be in the server's GAC.
One thing I do know is needed is a config setting that tells the system how to create a new instance of the provider. You can try to add that setting to your web.config and try if that is enough, but again, there may be a lot of dependent DLLs and settings you need for the Oracle provider to work.
The setting is (this is for another version of ODP.Net, you will find the correct settings in machine.config on your own machine):
<system.data>
<DbProviderFactories>
<add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client"
description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.112.1.2, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
GTG's solution provides at least part of the answer to my Question 1, so I am upvoting his solution. For anyone else interested in my Question 2 (how to perform an unobtrusive ODAC installation), an answer can be found here. (Look for AnthonyVO's answer, as it encapsulates all the necessary information.)
I should mention that I have not yet been able to get the unobtrusive solution to work for me, but many have, and it is the solution that I need to implement.
UPDATE: Case closed. I was missing an Oracle DLL. My full setup is shown here.

Resources