I am in the process of creating a blog site from scratch using MVC 3.0 and the Entity Framework. I am using a SQL CE .sdf file for the data store. This is stored in the projects App_Data folder. Locally, everything works fine. Not a problem. The .sdf file is read and processed without error. However, after using Web Deploy to publish to a shared hosting provider, I get the following error when trying to view the remote site:-
Access to the database file is not allowed
The connection string I am using in web config is:-
<connectionStrings>
<add name="DataAccess.BlogDbContext" connectionString="Data Source=DansMVCBlog.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
I have researched the problem and have hit a brick wall. Suggestions have included adding App_Data/DansMVCBlog.sdf to the connection string file path rather than just the file name. This does not work as you are advised the file path is invalid. On the shared hosting control panel, I have set read/write permissions on the App_Data folder to be true. Also, in my Global.asax file, I have disabled
`Database.SetInitializer(new DataInitializer());
Am I making a schoolboy error here? Does anyone have any suggestions? Thanks
Looks like the OP may have solved their problem but in my case, it turned out that the database file had been marked as Read Only by my source control system. Clearing the Read Only flag solved the problem.
You probably need to update your connection string
<connectionStrings>
<add name="DataAccess.BlogDbContext"
connectionString="Data Source=|DataDirectory|DansMVCBlog.sdf"
providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
Who knows what the solution to this was. All I can say is I was having problems publishing using web deploy, so I switched to using ftp. After that everything worked just fine.
Related
I have integrated Elmah.mvc via Nuget in my mvc application. It is storing logs properly but when i do any changes in web.config or restart the site all the error logs stored are erased. Is there a way to preserve its logs permanently in some location probably inside project folder or somewhere. Pls suggest.
Yes! All you have to do is tell Elmah to record logs in files instead of in memory, like this (in elmah's web.config session):
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
to save in memory it should be:
<errorLog type="Elmah.MemoryErrorLog, Elmah" size="1000"/>
Don't forget to allow write access on "logPath" folder.
I have two web services, of old school, asmx. Both is in the same sub folder, which have anonymous authentication, in a MVC web application that have windows authentication.
When I browse one of them I get expected result, I can Invoke the service, but when I browse the other I get "HTTP Error 401.2 - Unauthorized You are not authorized to view this page due to invalid authentication headers.".
I then rename the second one and everything works fine. Even if I remove the second asmx file I get Unauthorized, instead of "Resource not found".
I have searched the registry and the file system for references to the file name, but find nothing. I deleted ASP.NET Temporary Files, but that did not help.
Any trouble shooting suggestions?
This was not easy to find, but in inetpub\temp\appPools\ there was a folder named as the application pool. In that folder there is "copy" of parts of the IIS config.
At some point we must have accidentally marked the actual asmx file, instead of the folder when we changed autentication. So it contained a special configuration section for just the file. Like:
<location path="Web/Services/ServiceName.asmx">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
When we removed that section it worked again :)
I have googled for the past 3 hours and found nothing on what to do with respect to the windows azure problem:
You do not have permission to view this directory or page.
I did a git master push to azure and the deployment was successful. I also turned on the failed request tracing but nothing shows up but the above statement.
Any ideas on how to troubleshoot this?
I just tested that if you don't deploy your main node.js file as server.js you will get this error because the web.config is specifically looking for server.js as below:
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
To further troubleshot this issue you can access the website over FTP as described here.
AvkashChauhan's answer did lead me in the right direction but I also had to add proper rewriting rules. Here is my complete web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation batch="false" />
</system.web>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I hit this error too. I am using MVC and the reason for the error was that on my layout page I had a call to an action that isn't accessible to anonymous users:
#Html.Action("GetMenu", "Users")
For information, I register a AuthorizeAttribute() global filter in Application_Start and my Login action is decorated with AllowAnonymous:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
My website did work previously on IIS7, but Azure is less forgiving. I fixed the problem by adding a check like this:
#if (User.Identity.IsAuthenticated)
{
#Html.Action("GetMenu", "Users")
}
The azure tools have changed a lot since this question.
I recommend people using the azure-cli. But funny enough I actually don't use it after I have used it once to create a site.
What I use now is just the ability to push (git) directly to a remote that is named azure, and the cli is setting that up for you.
But if you don't want to install the cli you can essentially just add the remote repo (your site) manually, like this:
git remote add azure https://<site-or-appservice-name>.scm.azurewebsites.net/<site-or-appservice-name>.git
As you would with every other git remote.
Not specific to node.js but updating in case it helps others facing this issue for a regular web application. This can also happen if the index.html file is not present or is not found because it is in a sub-directory
I just came across this issue and in my case it was the ipSecurity configuration that was causing the issue. Just hd to go and change the allowUnlisted to true.
<security>
<ipSecurity allowUnlisted="false">
</security>
Simple configuration, in the azure portal go to your
web app ->
All settings ->
application settings,
under default documents add the specific name of your document which you want to view, wait for it to update, then refresh your azure link.
I had the same error message after a git push from a local repository.
Solved it by opening the Azure dashboard:
Web app / App deployment / deployment source
and selecting local git repository as deployment source
You need to move your server.js file to your root app folder.
Lots of answers, but I didn't see one that addressed the "how do I debug this?" question, which wasn't obvious to me as someone who is new to Azure and hadn't yet used Kudu diagnostics.
To see the debugging info you're looking for, just navigate to
mywebsite.scm.azurewebsites.net
when you encounter the "You do not have permission to view this directory or page." error on your own
mywebsite.azurewebsites.net
page. This will get you to the Kudu console and give you easy access to everything currently in your logs.
See also the many answers to the closed-but-popular How to debug "You do not have permission to view this directory or page"? question.
I have recently been trying to install TargetProcess on my windows 7 machine.
I have gotten so far as to successfully install it while running IIS and an SQLEXPRESS instance. when I point my web browser at the index page there is an error in the config file.
Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Reroute-x32-2.0'
Can anyone advise on how best to proceed?
thanks
Kevin
Sounds like an error (duplicate entry) in the site's web.config file. Have a look through the web.config or machine.config, look for something like
<add name="Reroute-x32-2.0" ...
Don't forget that config files are hierarchical, so you might have this entry in one config, and inadvertantly added it to another config file higher up in the IIS folder hierarchy (or machine.config).
My Asp.Net MVC project works on local machine without any problems. And, in my project, I use membership provider.
After I publish my site, some parts work correctly. However, membership system does not work. And error message is "Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'."
My Connection String is like this;
<add name="ApplicationServices" connectionString="Data Source=111.111.111.111;Initial Catalog=DBname;Persist Security Info=True; User Id=123123;Password=pass;" providerName="System.Data.SqlClient" />
<add name="DATABASE" connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;provider=System.Data.SqlClient;provider connection string="data source=111.111.111.111;Initial Catalog=DBname; User Id=123123;Password=pass;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
user login and register functions , which uses "ApplicationServices", does not work.
But, other functions, which connect database with "DATABASE", works correctly.
You will need to allow the application to show you errors.
"Sorry, an error occurred while processing your request." is a default message.
In your web.config (Under system.web) add the following.
<customErrors mode="off" />
Then report back with the error message you receive.
======= In Response to the Edit
The error is simply telling you that you havent imported one of the stored procedures. Make sure you've exported it from local (Via Generate Scripts or Backup).