I create a new solution/project using the Single Page Application template.
It all works well when running under the development/debug environment.
But then when I publish it to IIS with ASP.NET 4.5, it does not work so well.
When the page displays, I get the error: "An unknown error has occurred"
I tried to register a new user but the same error occurs. The username registration module generates the error in 3 places, so I modified the message on each one to identify which line is causing the issue:
So in IE11 I can set a breakpoint ( F12, click on left hand column ) on the point where the new Username/Password are validated, but nothing shows up in the console, or any indication of why it failed. "Unknown error" doesn't help much.
I can step through the lines from before until after, but nothing appears out of place.
<?xml version="1.0" encoding="UTF-8"?>
<log>
<version>1.1</version>
<creator>
<name>Internet Explorer Network Inspector</name>
<version>11.0.9600.17351</version>
</creator>
<browser>
<name>Internet Explorer</name>
<version>11.0.9600.17351</version>
</browser>
<pages>
<page>
<startedDateTime>2014-10-22T13:04:42.638-05:00</startedDateTime>
<id>0</id>
<title/>
<pageTimings>
<onContentLoad>-1</onContentLoad>
<onLoad>-1</onLoad>
</pageTimings>
</page>
</pages>
<entries>
<entry>
<pageref>0</pageref>
<startedDateTime>2014-10-22T13:04:45.232-05:00</startedDateTime>
<time>31</time>
<request>
<method>POST</method>
<url>http://win8envision/Token</url>
<httpVersion>HTTP/1.1</httpVersion>
<cookies/>
<headers>
<header>
<name>Accept</name>
<value>*/*</value>
</header>
<header>
<name>Content-Type</name>
<value>application/x-www-form-urlencoded; charset=UTF-8</value>
</header>
<header>
<name>X-Requested-With</name>
<value>XMLHttpRequest</value>
</header>
<header>
<name>Referer</name>
<value>http://win8envision/VCIWEBPortal</value>
</header>
<header>
<name>Accept-Language</name>
<value>en-US</value>
</header>
<header>
<name>Accept-Encoding</name>
<value>gzip, deflate</value>
</header>
<header>
<name>User-Agent</name>
<value>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729)</value>
</header>
<header>
<name>Host</name>
<value>win8envision</value>
</header>
<header>
<name>Content-Length</name>
<value>64</value>
</header>
<header>
<name>DNT</name>
<value>1</value>
</header>
<header>
<name>Connection</name>
<value>Keep-Alive</value>
</header>
<header>
<name>Cache-Control</name>
<value>no-cache</value>
</header>
</headers>
<queryString/>
<postData>
<mimeType>application/x-www-form-urlencoded</mimeType>
<text>grant_type=password&username=ffffff&password=sssssssssssssssssss</text>
</postData>
<headersSize>488</headersSize>
<bodySize>64</bodySize>
</request>
<response>
<status>404</status>
<statusText>Not Found</statusText>
<httpVersion>HTTP/1.1</httpVersion>
<cookies/>
<headers>
<header>
<name>Cache-Control</name>
<value>private</value>
</header>
<header>
<name>Content-Type</name>
<value>text/html; charset=utf-8</value>
</header>
<header>
<name>Server</name>
<value>Microsoft-IIS/8.5</value>
</header>
<header>
<name>X-Powered-By</name>
<value>ASP.NET</value>
</header>
<header>
<name>Date</name>
<value>Wed, 22 Oct 2014 13:04:45 GMT</value>
</header>
<header>
<name>Content-Length</name>
<value>4830</value>
</header>
</headers>
<content>
<size>4830</size>
<mimeType>text/html; charset=utf-8</mimeType>
<text><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>IIS 8.5 Detailed Error - 404.0 - Not Found</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;}
code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;}
.config_source code{font-size:.8em;color:#000000;}
pre{margin:0;font-size:1.4em;word-wrap:break-word;}
ul,ol{margin:10px 0 10px 5px;}
ul.first,ol.first{margin-top:5px;}
fieldset{padding:0 15px 10px 15px;word-break:break-all;}
.summary-container fieldset{padding-bottom:5px;margin-top:4px;}
legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;}
legend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px;
font-weight:bold;font-size:1em;}
a:link,a:visited{color:#007EFF;font-weight:bold;}
a:hover{text-decoration:none;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.4em;margin:10px 0 0 0;color:#CC0000;}
h4{font-size:1.2em;margin:10px 0 5px 0;
}#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS",Verdana,sans-serif;
color:#FFF;background-color:#5C87B2;
}#content{margin:0 0 0 2%;position:relative;}
.summary-container,.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
.content-container p{margin:0 0 10px 0;
}#details-left{width:35%;float:left;margin-right:2%;
}#details-right{width:63%;float:left;overflow:hidden;
}#server_version{width:96%;_height:1px;min-height:1px;margin:0 0 5px 0;padding:11px 2% 8px 2%;color:#FFFFFF;
background-color:#5A7FA5;border-bottom:1px solid #C1CFDD;border-top:1px solid #4A6C8E;font-weight:normal;
font-size:1em;color:#FFF;text-align:right;
}#server_version p{margin:5px 0;}
table{margin:4px 0 4px 0;width:100%;border:none;}
td,th{vertical-align:top;padding:3px 0;text-align:left;font-weight:normal;border:none;}
th{width:30%;text-align:right;padding-right:2%;font-weight:bold;}
thead th{background-color:#ebebeb;width:25%;
}#details-right th{width:20%;}
table tr.alt td,table tr.alt th{}
.highlight-code{color:#CC0000;font-weight:bold;font-style:italic;}
.clear{clear:both;}
.preferred{padding:0 5px 2px 5px;font-weight:normal;background:#006633;color:#FFF;font-size:.8em;}
-->
</style>
</head>
<body>
<div id="content">
<div class="content-container">
<h3>HTTP Error 404.0 - Not Found</h3>
<h4>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h4>
</div>
<div class="content-container">
<fieldset><h4>Most likely causes:</h4>
<ul> <li>The directory or file specified does not exist on the Web server.</li> <li>The URL contains a typographical error.</li> <li>A custom filter or module, such as URLScan, restricts access to the file.</li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>Things you can try:</h4>
<ul> <li>Create the content on the Web server.</li> <li>Review the browser URL.</li> <li>Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>Detailed Error Information:</h4>
<div id="details-left">
<table border="0" cellpadding="0" cellspacing="0">
<tr class="alt"><th>Module</th><td>&nbsp;&nbsp;&nbsp;IIS Web Core</td></tr>
<tr><th>Notification</th><td>&nbsp;&nbsp;&nbsp;MapRequestHandler</td></tr>
<tr class="alt"><th>Handler</th><td>&nbsp;&nbsp;&nbsp;StaticFile</td></tr>
<tr><th>Error Code</th><td>&nbsp;&nbsp;&nbsp;0x80070002</td></tr>
</table>
</div>
<div id="details-right">
<table border="0" cellpadding="0" cellspacing="0">
<tr class="alt"><th>Requested URL</th><td>&nbsp;&nbsp;&nbsp;http://win8envision:80/Token</td></tr>
<tr><th>Physical Path</th><td>&nbsp;&nbsp;&nbsp;C:\inetpub\wwwroot\Token</td></tr>
<tr class="alt"><th>Logon Method</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr>
<tr><th>Logon User</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr>
</table>
<div class="clear"></div>
</div>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>More Information:</h4>
This error means that the file or directory does not exist on the server. Create the file or directory and try the request again.
<p><a href="http://go.microsoft.com/fwlink/?LinkID=62293&amp;IIS70Error=404,0,0x80070002,9600">View more information &raquo;</a></p>
</fieldset>
</div>
</div>
</body>
</html>
</text>
</content>
<redirectionURL/>
<headersSize>199</headersSize>
<bodySize>4830</bodySize>
</response>
<cache/>
<timings>
<send>15</send>
<wait>0</wait>
<receive>0</receive>
</timings>
</entry>
</entries>
</log>
Clearly the "code" is requesting something called "token"
My first concern is that the "Single Page Application" template from the Visual Studio 2013 treats this error as "an unknown error has occurred." Clearly a very descriptive message of the error is passed from the server to the client and this message should
be available in the point in the code where "An unknown error has occurred."
So my first question is : How to display this error text in the display page instead of the vague text that is displayed?
My second question: What is this "token" resource and how should it be "deployed?"
to answer my previous question I believe this is the accepted practice:
self.errors.push("An unknown error occurred.(viewmodel.js line 62 self.register 3)" );
if (arguments.length > 0)
{
var obj = arguments[2].responseText;
self.errors.push(obj);
var x = window.open();
x.document.open();
x.document.write(obj);
x.document.close();
}
This generates the following page::
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Most likely causes:
•The directory or file specified does not exist on the Web server.
•The URL contains a typographical error.
•A custom filter or module, such as URLScan, restricts access to the file.
Things you can try:
•Create the content on the Web server.
•Review the browser URL.
•Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:
Module
IIS Web Core
Notification
MapRequestHandler
Handler
StaticFile
Error Code
0x80070002
Requested URL
http://win8envision:80/api/Account/Register
Physical Path
C:\inetpub\wwwroot\api\Account\Register
Logon Method
Anonymous
Logon User
Anonymous
More Information:
This error means that the file or directory does not exist on the server. Create the file or directory and try the request again.
View more information »
The problem seems to be in the hand-off between VS2013 and IIS.
The Controller DLL is being moved to inetpub/wwwroot/<projectname>/bin/<projectname>.dll
but the IIS Manager application only has the /bin/ directory in the list of directories, no references to the virtual directories referenced in the <projectname>.dll library.
By default, the StaticFile handler or the Directory handler will handle a request when a client requests a file that has an extension or a directory that is not mapped to a handler. When a client requests a URL with a specific file but the extension does not map to a handler, the StaticFile handler will try to process the request. When a client requests a URL without specifying a file, the Directory handler will return either a default document or a directory listing depending on whether those options are enabled for the application. If you want a handler other than the StaticFile handler or the Directory handler to process a request, you can create a new handler mapping.
And StaticFile shows up as the handler in the verbose 404 error message.
My concern is that in IIS, there are so many options for configuring a "Handler Mappings" I do not know which is the correct option:
Could you please try to change app.datamodel.js routes to indicate your sub directory of IIS and see if it works?
e.g. from
// Routes
self.userInfoUrl = "/api/Me";
self.siteUrl = "/";
to
// Routes
self.userInfoUrl = "/projectName/api/Me";
self.siteUrl = "/projectName/";
The default route is for a complete site, e.g. if you publish it to an Azure website. Since it looks like you are publishing to a sub directory of IIS default website, you might need to change all the / to /projectName/ in all the js files.
Thanks and Best Regards
Xinyang Qiu, Azure Web Platform and Tools team, Microsoft
I hope the following article will help you since looks like you didn't changer your web.config connection string to a installed SQL Server, and you are still trying to use localdb for your sqlserver.
Member
2 Points
23 Posts
newbie getting started
Oct 20, 2014 01:44 PM|BDM|LINK
I set up my environment from scratch
I have Windows 8.1 v 6.3.9600
I have Visual Studio Premium 2013
I create a new solution/project using the Single Page Application template.
It all works well when running under the development/debug environment.
But then when I publish it to IIS with ASP.NET 4.5, it does not work so well.
When the page displays, I get the error: "An unknown error has occurred"
I tried to register a new user but the same error occurs. The username registration module generates the error in 3 places, so I modified the message on each one to identify which line is causing the issue:
It is the last occurrence: "(viewmodel.js self.register 3)" that generates the error.
Is this some configuration that has to be set under IIS or ASP.NET ?
Please advise.
Boyd
All-Star
16806 Points
2777 Posts
Re: newbie getting started
Oct 21, 2014 04:57 AM|Kevin Shen - MSFT|LINK
Hi BDM,
For your issue ,I suggest that you can set a breakpoint on your javascript code. and press F12 to debug
Check if it has any error message.
Best Regards,
Kevin Shen.
Member
2 Points
23 Posts
Re: newbie getting started
Oct 21, 2014 10:17 AM|BDM|LINK
In the Browser debugger, I break on the line:
So in IE11 I can set a breakpoint ( F12, click on left hand column ) on the point where the new Username/Password are validated, but nothing shows up in the console, or any indication of why it failed. "Unknown error" doesn't help much.
I can step through the lines from before until after, but nothing appears out of place.
Please advise.
Boyd
Member
2 Points
23 Posts
Re: newbie getting started
Oct 21, 2014 02:00 PM|BDM|LINK
I suspect the code is not getting to the accountController.cs
How can I prove it is not getting to the "code behind" accountController.cs when launched through IIS when it does work when launched within VS2013?
When running the published product, how can I debug/step_into the accountController.cs code?
Boyd
All-Star
16806 Points
2777 Posts
Re: newbie getting started
Oct 22, 2014 03:44 AM|Kevin Shen - MSFT|LINK
Hi BDM,
I suggest that you can press F12 and click the NetWork tab,enable the network traffic capturing.
check if the js code have sent the request to the server behind,check the response body and request body for the request.
check if it has any error message.
Best Regards,
Kevin Shen.
Member
2 Points
23 Posts
Re: newbie getting started
Oct 22, 2014 09:20 AM|BDM|LINK
Thank you Kevin, that has helped quite a bit.
The network traffic is as follows:
Clearly the "code" is requesting something called "token"
My first concern is that the "Single Page Application" template from the Visual Studio 2013 treats this error as "an unknown error has occurred." Clearly a very descriptive message of the error is passed from the server to the client and this message should be available in the point in the code where "An unknown error has occurred."
So my first question is : How to display this error text in the display page instead of the vague text that is displayed?
My second question: What is this "token" resource and how should it be "deployed?"
Boyd
SPA
Member
2 Points
23 Posts
Re: newbie getting started
Oct 22, 2014 01:35 PM|BDM|LINK
I am a little bit closer.
At the end of the module, I now have the following:
Arguments . length is 3, no surprise there.
In the IE11 debugger, the [2] argument contains the verbose error response from the server.
But as written the displayed text is "[object Object]"
So a java syntax question: how do I convert [object Object] into the text string it contains ?
Boyd
Member
2 Points
23 Posts
Re: newbie getting started
Oct 22, 2014 03:04 PM|BDM|LINK
to answer my previous question I believe this is the accepted practice:
This generates the following page::
Ok, so:
http://win8envision:80/api/Account/Register
Is not "published" as part of the Single Page Application. How is this done?
Boyd
All-Star
16806 Points
2777 Posts
Re: newbie getting started
Oct 23, 2014 10:10 PM|Kevin Shen - MSFT|LINK
Hi BDM,
Since your application run very under development,while failed in deploying into IIS.
It maybe related with IIS Configuration ,I suggest that you can post your issue to the IIS forum for a professional issue:
http://forums.iis.net/default.aspx/41?IIS+7+and+Above
Best Regards,
Kevin Shen.
Member
2 Points
23 Posts
Re: newbie getting started
Oct 24, 2014 09:10 AM|BDM|LINK
Thanks Kevin,
I really don't think the issue is with IIS.
The Controller is just not there.
I believe the issue is with one of:
The view/viewmodel gets published, but not the controller.
Please advise
Boyd
All-Star
16806 Points
2777 Posts
Re: newbie getting started
Oct 27, 2014 03:31 AM|Kevin Shen - MSFT|LINK
Hi BDM,
Since your code run very well in your development environment and it failed on publishing your project in iis ,
So I guess it is more related with iis configuration,and I suggest that you can have a try.
and if not,we can narrow the possibility cause for your issue.
Best Regards,
Kevin Shen.
Member
2 Points
23 Posts
Re: newbie getting started
Oct 28, 2014 10:26 AM|BDM|LINK
Hi Kevin,
I think you are right.
The problem seems to be in the hand-off between VS2013 and IIS.
The Controller DLL is being moved to inetpub/wwwroot/<projectname>/bin/<projectname>.dll
but the IIS Manager application only has the /bin/ directory in the list of directories, no references to the virtual directories referenced in the <projectname>.dll library.
Please advise
Boyd
Member
2 Points
23 Posts
Re: newbie getting started
Oct 29, 2014 09:46 AM|BDM|LINK
I am closer to the cause of the problem.
http://technet.microsoft.com/en-ca/library/cc771240(v=ws.10).aspx
contains:
And StaticFile shows up as the handler in the verbose 404 error message.
My concern is that in IIS, there are so many options for configuring a "Handler Mappings" I do not know which is the correct option:
- add managed handler
- add script map
- add WildCard Script Map
- add Module Mapping
Please advise
Boyd
All-Star
16806 Points
2777 Posts
Re: newbie getting started
Oct 30, 2014 08:20 PM|Kevin Shen - MSFT|LINK
Hi BDM,
Since it is related with iss which i am not familar ,i suggest that you can post it to iis forum for a professional soultion:
http://forums.iis.net/default.aspx/41?IIS+7+and+Above
Best Regards,
Kevin Shen.
Member
313 Points
154 Posts
Microsoft
Re: newbie getting started
Oct 31, 2014 09:11 PM|xinqiu|LINK
Could you please try to change app.datamodel.js routes to indicate your sub directory of IIS and see if it works?
e.g. from
// Routes
self.userInfoUrl = "/api/Me";
self.siteUrl = "/";
to
// Routes
self.userInfoUrl = "/projectName/api/Me";
self.siteUrl = "/projectName/";
The default route is for a complete site, e.g. if you publish it to an Azure website. Since it looks like you are publishing to a sub directory of IIS default website, you might need to change all the / to /projectName/ in all the js files.
Xinyang Qiu, Azure Web Platform and Tools team, Microsoft
Member
2 Points
23 Posts
Re: newbie getting started
Nov 03, 2014 10:44 AM|BDM|LINK
Thank you Xinqiu,
That certainly got me over a major hurdle.
Now smack into the next one.......
But I think this is an IIS configuration issue.
The example now runs great up until the "register" to register a username/password to a local buffer.
I have used F12 debug, monitored the network traffic, and saw that the correct controller is being called.
But:
I think IIS is intercepting the request and failing the privileges test to forward the request to the controller.
Please advise.
Boyd
Member
313 Points
154 Posts
Microsoft
Re: newbie getting started
Nov 03, 2014 12:58 PM|xinqiu|LINK
I hope the following article will help you since looks like you didn't changer your web.config connection string to a installed SQL Server, and you are still trying to use localdb for your sqlserver.
http://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-1-user-profile.aspx
http://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-2-instance-ownership.aspx
Xinyang Qiu, Azure Web Platform and Tools team, Microsoft