Getting access denied error when deploying RavenDB embedded application to IIS

908 views
Skip to first unread message

imgen

unread,
Sep 26, 2011, 6:04:43 AM9/26/11
to ravendb
I built a web app using RavenDB Embedded mode. But when I deploy it to
IIS, it gives me "Access denied" error for the line
_documentStore.Initialize();
I want to know what kind of requirement is for RavenDB Embedded
website?
It runs OK with ASP.NET Development server.

Ayende Rahien

unread,
Sep 26, 2011, 6:08:25 AM9/26/11
to rav...@googlegroups.com
Likely a permissions errors because IIS doesn't have rights to write to the directory

imgen

unread,
Sep 26, 2011, 6:11:19 AM9/26/11
to ravendb
How to resolve it? Grant write permission to IIS?
> > It runs OK with ASP.NET Development server.- Hide quoted text -
>
> - Show quoted text -

Ayende Rahien

unread,
Sep 26, 2011, 6:17:48 AM9/26/11
to rav...@googlegroups.com
yes

imgen

unread,
Sep 26, 2011, 7:26:53 AM9/26/11
to ravendb
Unfortunately, after I edit permission for both the website (which is
Default Web Site) and the application (which is my little web app)
with Write permission for both IUSER and IIS_IUSERS, and restarted the
app pool (which is DefaultAppPool with ASP.NET 4.0 runtime), the
application still gives me access denied error when initialize RavenDB
document store.
I'm using the latest nuget package of RavenDB Embedded. Is there
anything that I have to specifically set or something?
And that I look at the trust level, both the site and application are
set to Full trust level.
Do I need a reboot? Or else?
> > > - Show quoted text -- Hide quoted text -

imgen

unread,
Sep 26, 2011, 7:29:28 AM9/26/11
to ravendb
BTW, I'm using the IIS Manager to do the job - right click on site
node / application node and click "Edit Permissions" menu item, then
in the "Security" tab to set the permission for individual user. Is it
the correct way?

Ayende Rahien

unread,
Sep 26, 2011, 7:58:17 AM9/26/11
to rav...@googlegroups.com
Pretty sure that it isn't, we are talking about NTFS permissions here.
If the problem persists, please post the entire exception including stack trace here.

imgen

unread,
Sep 26, 2011, 8:08:42 AM9/26/11
to ravendb
I can confirm that the dialog popped up when click "Edit
Permissions..." is the same with the dialog that popped up after click
"Properties" in the Windows Explorer. And here is the full error.

Server Error in '/THEILink/API' Application.
--------------------------------------------------------------------------------

Access is denied
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.Net.HttpListenerException: Access is denied

Source Error:


Line 67:
Line 68:
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(80);
Line 69: _documentStore.Initialize();
Line 70:
Line 71: //MemberRepository.NormalizeOldRecords();


Source File: E:\Work\Projects\THEILink\src\THEILink.API
\Global.asax.cs Line: 69

Stack Trace:


[HttpListenerException (0x5): Access is denied]
System.Net.HttpListener.AddAllPrefixes() +335
System.Net.HttpListener.Start() +883
Raven.Http.HttpServer.Start() in c:\Builds\raven\Raven.Http
\HttpServer.cs:149
Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal()
in c:\Builds\raven\Raven.Client.Embedded\EmbeddableDocumentStore.cs:
141
Raven.Client.Document.DocumentStore.Initialize() in c:\Builds\raven
\Raven.Client.Lightweight\Document\DocumentStore.cs:478
THEILink.API.MvcApplication.InitializeStore() in E:\Work\Projects
\THEILink\src\THEILink.API\Global.asax.cs:69
THEILink.API.MvcApplication.Application_Start() in E:\Work\Projects
\THEILink\src\THEILink.API\Global.asax.cs:47

[HttpException (0x80004005): Access is denied]

System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) +4053077
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers, IntPtr appContext, HttpContext context) +352

System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +375

[HttpException (0x80004005): Access is denied]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context)
+11689168
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+141

System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +4865173

Ayende Rahien

unread,
Sep 26, 2011, 8:10:36 AM9/26/11
to rav...@googlegroups.com
Okay, that is an HTTP LISTERNER exception, that means that you need to grant rights in http.sys to the IIS user.
You can do it with:
netsh http add urlacl url=http://+:THE_PORT/ user="THE_USER"

imgen

unread,
Sep 26, 2011, 8:17:24 AM9/26/11
to ravendb
Ok. I think I sort of understand what has gone wrong. I set
UseEmbeddedHttpServer to true which is causing the issue. After I set
it to false, the initialization worked. Although I still get some
error but I think it's other issues instead of RavenDB.
Is this a bug of RavenDB embedded? I don't know. But I'm glad it's now
fixed.

On Sep 26, 8:08 pm, imgen <imge...@gmail.com> wrote:
> I can confirm that the dialog popped up when click "Edit
> Permissions..." is the same with the dialog that popped up after click
> "Properties" in the Windows Explorer. And here is the full error.
>
> Server Error in '/THEILink/API' Application.
> ---------------------------------------------------------------------------­-----
> System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(Htt­pContext

imgen

unread,
Sep 26, 2011, 8:26:56 AM9/26/11
to ravendb
Thx. Great. You are man of the hour. You cleared up the Pearl Jam. :)

imgen

unread,
Sep 26, 2011, 9:13:30 AM9/26/11
to ravendb
Sorry. Almost half an hour past and I tried with your command and
searched on Internet quite a lot, but now instead of access denied, I
get a
HTTP Error 503. The service is unavailable.
error.
I used the command like this:
netsh http add urlacl url=http://+:80/THEILink/API user=IIS_IUSRS
and
netsh http add urlacl url=http://+:80/THEILink/API user=IUSR

I tried both. Both give me the same error. I guess in the end, maybe
it's possible this is a bug of that IIS and RavenDB doesn't play well
together.

Ayende Rahien

unread,
Sep 26, 2011, 9:18:57 AM9/26/11
to rav...@googlegroups.com
You are trying to host RavenDB embedded inside IIS, and on top of that to run RavenDB's own HTTP Listener on the same port that IIS is listening to?
That isn't going to work.
What is it that you are actually trying to do?

imgen

unread,
Sep 26, 2011, 9:35:28 AM9/26/11
to ravendb
No. I'm just trying to use RavenDB Embedded in my app with
UseEmbeddedHttpServer set to true. That's all. Nothing else. I didn't
install RavenDB on my IIS server. I'm putting this app under IIS'
Default Web Site. Could it be that because I didn't put this web app
in a separate website? Anyway. I'll try to do just that.

Ayende Rahien

unread,
Sep 26, 2011, 9:36:46 AM9/26/11
to rav...@googlegroups.com
UseEmbeddedHttpServer <-- run ravendb's own http server

imgen

unread,
Sep 26, 2011, 9:43:11 AM9/26/11
to ravendb
The thing is that it works fine under ASP.NET Development Server. As
soon as I move to IIS, things fall into chaos.
Do you mean that this is impossible? We can not use RavenDB embedded
with UseEmbeddedHttpServer set to true?

Ayende Rahien

unread,
Sep 26, 2011, 9:45:38 AM9/26/11
to rav...@googlegroups.com
You set the embedded server to use port 80? That is what IIS is running on

imgen

unread,
Sep 26, 2011, 9:47:46 AM9/26/11
to ravendb
So have to be 8080 or anything other than 80

Ayende Rahien

unread,
Sep 26, 2011, 9:49:50 AM9/26/11
to rav...@googlegroups.com
Yes

imgen

unread,
Sep 26, 2011, 9:56:18 AM9/26/11
to ravendb
I did. I set it to 8080 before calling Initialize method, then add url
reservation using command
netsh http add urlacl url=http://+:8080/ user=IIS_IUSRS
then restart the website. To no avail. Still Service Unavailable
error.
> ...
>
> read more »- Hide quoted text -

imgen

unread,
Sep 26, 2011, 9:59:36 AM9/26/11
to ravendb
And when I use ASP.NET Development Server, the url
http://localhost:8080/raven/documents.html
will show the WebUI of RavenDB. But in IIS, the url gives me nothing.

imgen

unread,
Sep 26, 2011, 10:01:35 AM9/26/11
to ravendb
I think webui is an important part of RavenDB, it's clean and
powerful. That's why I tried so hard to get it working. Our app will
be hosted by some hosting service so it's may not be possible to host
RavenDB as a separate website.
Reply all
Reply to author
Forward
0 new messages