Asked by:
Data at the root level is invalid. Line 1, position 1

Question
-
User-714328298 posted
A C# ASP.NET program under development (VS 2005) works fine in the development box, using the virtual localhost server.
Once I tried to "Publish" the site, pressing the [Build->Publish Web Site] menu option, it compiles and gives the following error:"Data at the root level is invalid. Line 1, position 1."
The compilation fails at line 1, the line containing the [xml version="1.0" encoding="utf-8"] declaration.
The simplied web.config file is shown below. As you can see it has nothing out of the ordinary.<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
blah blah...
</connectionStrings>
<appSettings>
blah blah...
</appSettings>
blah blah...
blah blah...
</configuration>I have googled and found a few entries on this error, most of them talking about SOAP and web services (not what I'm doing here), and none of them have helped.
I tried to recompile taking out the encoding=utf-8 section and also taking out the xmlns definition buit I still get the same error.
Any ideas to try next?
TIA
Thursday, April 27, 2006 11:31 AM
All replies
-
User274133862 posted
Hi fsflier,
A few ideas:
- Can you confirm that the XML is well formed? Have you tried to open the XML file using IE and ensuring that there are no errors?
- Make sure there is no blank space before the root element.
- Maybe its a security problem? You could temporarily grant full access to that XML file and at least rule out the possibility.
James Steele
Thursday, April 27, 2006 1:47 PM -
User-714328298 posted
Thanks James but that has been tested. It is well formed. It opens fine in IE and it works fine in VS2005 and when testing the app in localhost.
There is no blank space before the first statement. One of the things I have tried is to see if there was anything starnge in Line 1, Position 1. When adding a top blank line the compiler complained that the XML line was not the first line. There is nothing wrong with the line per se.
I did not suspect a security/access problem but it is something to try. Unfortunately that is not the case either.
Thanks for the ideas. Still looking.
Thursday, April 27, 2006 2:26 PM -
User-177161035 posted
I've seen this error when there is no file where the object is trying to open it from.
Make sure that the path you are specifiying is FOR sure where the file is.
Thursday, April 27, 2006 7:05 PM -
User-714328298 posted
jbat1:
I don't understand your post. I'm not sure what path are we talking about as I'm not trying to run or open at this stage. All I'm doing is compiling/publishing to My Documents
These are the exact steps:
- I have an ASP.NET project inVS2005. It has a web.config
- The source files reside in a different server (our development server)
- I presss F5 to run locally (debugger) and it compiles ionm the fly and opens the default page in a temporary fake IIS in localhost (my workstaion does not have IIS). Everything works fine.
- Project is finished. I want now to publish and start testing in QA/Staging server.
- I open menu option: [Build->Publish Web Site]. A dialog appears pointing to my target location. This is in my local PC in MyDocuments\Visual Studio 2005\Projects\<my project>\Precompiled\<project name>. The only checkbox clicked (by default) is the first one: "Allow precompiled site to be updatable". Press OK
- It compiles for a while and then comes up with this error: Data at root level is invalid...
Thanks for the insight.
Friday, April 28, 2006 9:29 AM -
User-714328298 posted
More info:
When I double-click on the error it opens another file (tab) also called web.config with the following exact contents:
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|22 Mar 2006 13:48:12 -0000
vti_extenderversion:SR|4.0.2.7802
vti_cacheddtm:TX|22 Mar 2006 13:48:12 -0000
vti_filesize:IR|6249I do not know what this info means or where it points to and why it mentions a 22 March date. I went to a co-developer and we created the project in his VS2005 (in his PC) and pointed to my existing app in the development server. He got the exact same error, thereby certifying that it is not my local PC and/or my copy of VS2005 but something wrong with the source.
Still stuck. :(
Friday, April 28, 2006 10:46 AM -
User-177161035 posted
Dangit! you caught me... sorry I just saw the error message, and honestly did not entirely read your post. I can see why you'd be confused.
I don't have anything helpful for you on this one.
Friday, April 28, 2006 11:32 AM -
User-714328298 posted
Found the problem!
I checked the path to the file it was complaining about: [myProject]\_vti_cnf\web.config and saw that it was not a well-formed XML file. As it is called web.config it was confusing. I deleted the file and the problem was solved. Wonder why it was created to begin with. It shows I'm starting with ASP.NET, doesn't it. <bg>
Monday, May 1, 2006 9:49 AM -
User274133862 posted
Alright. Well I am not sure we helped much, but I'm glad you are back up and running. Good stuff.
James SteeleMonday, May 1, 2006 11:37 AM -
User-1873565163 posted
Good one
thanks for the solution
I suspect the rogue file was left over from an upgrade from 2003
Friday, September 1, 2006 12:44 PM -
User1035933433 posted
Exactly right. I upgraded a project, had it working perfectly, but couldn't publish it. That spurious _vti_cnf\web.config was there. Getting rid of it fixed my problem straight away. Thanks for the tip.Thursday, October 5, 2006 9:09 PM -
User-1657135673 posted
I just started getting this. Didn't do anything I know of. I have verified this file is there and works. Looked in side of it.
Wss 3.0 has been running great until 11:00am today, didn't change anything.Line 1, position 1 looks like this in the document
<browsers>
<browser id="Safari2" parentID="Safari1Plus">
<controlAdapters>
<adapter controlType="System.Web.UI.WebControls.Menu"
adapterType="" />
What am I missing here? Please Help
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Data at the root level is invalid. Line 1, position 1.
Source Error:
Line 1: <browsers> Line 2: <browser id="Safari2" parentID="Safari1Plus"> Line 3: <controlAdapters>
Source File: /App_Browsers/compat.browser Line: 1
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
[HttpParseException]: Data at the root level is invalid. Line 1, position 1.
at System.Web.Configuration.BrowserCapabilitiesCodeGenerator.ProcessBrowserFiles(Boolean useVirtualPath, String virtualDir)
at System.Web.Compilation.ApplicationBrowserCapabilitiesCodeGenerator.GenerateCode(AssemblyBuilder assemblyBuilder)
at System.Web.Compilation.ApplicationBrowserCapabilitiesBuildProvider.GenerateCode(AssemblyBuilder assemblyBuilder)
at System.Web.Compilation.AssemblyBuilder.AddBuildProvider(BuildProvider buildProvider)
[HttpParseException]: Data at the root level is invalid. Line 1, position 1.
at System.Web.Compilation.AssemblyBuilder.AddBuildProvider(BuildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BrowserCapabilitiesCompiler.GetBrowserCapabilitiesType()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
[HttpException]: Data at the root level is invalid. Line 1, position 1.
at System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters)
[HttpException]: Data at the root level is invalid. Line 1, position 1.
at System.Web.HttpRuntime.FirstRequestInit(HttpContext context)
at System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)Also getting this
Event Type: Failure Audit
Event Source: Security
Event Category: Object Access
Event ID: 560
Date: 3/29/2007
Time: 1:00:03 PM
User: *****\wss3pooldemo
Computer: *****Description:
Object Open:
Object Server: SC Manager
Object Type: SERVICE OBJECT
Object Name: WinHttpAutoProxySvc
Handle ID: -
Operation ID: {0,19961704}
Process ID: 840
Image File Name: C:\WINDOWS\system32\services.exe
Primary User Name: BLYSERVER$
Primary Domain: *****
Primary Logon ID: (0x0,0x3E7)
Client User Name: wss3pooldemo
Client Domain: *****
Client Logon ID: (0x0,0x12E8C23)
Accesses: Query status of service
Start the service
Query information from service
Privileges: -
Restricted Sid Count: 0
Access Mask: 0x94
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.and this one
Event Type: Warning
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1310
Date: 3/29/2007
Time: 1:06:42 PM
User: N/A
Computer: *****
Description:
Event code: 3006
Event message: A parser error has occurred.
Event time: 3/29/2007 1:06:42 PM
Event time (UTC): 3/29/2007 7:06:42 PM
Event ID: 45e791819dd04c249a7e269ddc530641
Event sequence: 1
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1032202749/Root-7-128196688021727606
Trust level: WSS_Minimal
Application Virtual Path: /
Application Path: C:\Inetpub\wwwroot\wss\VirtualDirectories\80\
Machine name: *****
Process information:
Process ID: 3804
Process name: w3wp.exe
Account name: *****\dealer
Exception information:
Exception type: HttpException
Exception message: Data at the root level is invalid. Line 1, position 1.
Request information:
Request URL: http://*****/it/_vti_bin/lists.asmx
Request path: /it/_vti_bin/lists.asmx
User host address: 172.16.1.98
User:
Is authenticated: False
Authentication Type:
Thread account name: *****\dealer
Thread information:
Thread ID: 1
Thread account name: *****\dealer
Is impersonating: False
Stack trace: at System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters)
Custom event details:For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Event Type: Error
Event Source: DCOM
Event Category: None
Event ID: 10016
Date: 3/29/2007
Time: 1:00:02 PM
User: *****\wss3pooldemo
Computer: *****Description:
The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
{61738644-F196-11D0-9953-00C04FD919C1}
to the user BLYTHEDESIGN\wss3pooldemo SID (S-1-5-21-4239727938-222710763-1804924817-1486). This security permission can be modified using the Component Services administrative tool.For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Solution
I would like to meet the person that made this part of the system work as it does. I fixed this error I would think many people might have this over time.
Idea of what could be the issues was only found here.
http://forums.asp.net/thread/1270047.aspx
In doing some editting on the intranet site which is WSS v3 I openned a file called web.config from the c:\inetpub\wwwroot\wss\virutaldirectories\80
ok so no big deal didn't edit the file or change anything. I openned the file with SharePoint Designer after I did this I remembered I needed to work in these files in Virtual web designer and not sharepoint designer ok my bad didn't save anything seems stupid but I didn't give it a thought.
Just openning the file seems to be enough to have the system create a sub folder called _vti_pvt or something like that. In trouble shoot this error I openned a few files and it created this folder and made a copy of each file I openned and put it in a sub folder with the same name I found 6 of these folders all new. I guess this file is not a true xml file and made the whole site crash for 2 hours.
I deleted these directories and everything worked right away.
The person that set this up should be shot.
Thursday, March 29, 2007 4:48 PM -
User-544148771 posted
Thanks Jbenisek. My site is up and running again.[:)]Wednesday, May 23, 2007 3:02 AM -
User-898770386 posted
Just try Xml.Load() function instead of Xml.LoadXml().
Thursday, July 12, 2007 12:08 AM -
User-1552299067 posted
great!
Xml.LoadXml(). solved me the problem thanks
but where is the diffrence?
Wednesday, July 25, 2007 4:43 PM -
User-493178599 posted
I have the same problem ! who can help me! I am pool in English !
Friday, August 10, 2007 1:39 AM -
User1415983342 posted
In order to investigate performance problems I downloaded the website from remote hosting.
ASP.NET2.0+MSSQL2005 in both remote and local site.I could not compile it locally having
"Data at the root level is invalid. Line 1, position 1" error
until I deleted all _vti* files and folders (_vti_cnf\, _vti_pvt\, _vti_script\, etc.).Internet search shows that it is created by FPE (FrontPage Extensions) http://www.issociate.de/board/post/463236/_vti_cnf_folders.html tells:
"ignore them, but do not remove them from your local site."Hummm, I am confused - where are they created and for what?
And what about deleting them on server?
Friday, December 28, 2007 4:51 PM -
User2145089859 posted
Go to C:\Inetpub\wwwroot\wss\VirtualDirectories\ find your WSS Web Application (represented by a port number), then delete an unknown folder created by sharepoint, namely vti_cnf from all the folders and sub-folders in your web application, the error disappears. It may come because we have tried to edit the WSS web application having Form based authentication, atleast in my case it got resolved by deleting this junk folder...
Tuesday, April 1, 2008 7:33 AM -
User-1794709434 posted
I found that if the first line of web.config does not have a space before the closing ?, I get the "data at the root level is invalid. Line 1, position 1." error. In your example you are also missing the extra space.
<?xml version="1.0" encoding="utf-8"?> (CAUSES ERROR)
<?xml version="1.0" encoding="utf-8" ?> (WORKS LIKE A DREAM)
regards
Ian
Wednesday, May 14, 2008 4:57 AM -
User-1950211896 posted
Thanks Jbenisek for that post.
I had the same problem, I only open my sharepoint web site with Sharepoint Designer 2007 without saving anything , and voila, everything exploded. It had nothing to do with any permissions with ASP or changes to any web.config files, I did a hard drive seach and all the date stamp on all the web.config were untouched. I must say that all theses stupid events are pushing us to the wrong side of the problem. I saw these folders created by SD 2007 when i compared with yesterday's set of backups, but I didn't care, they were only inoffensive folders... When i read your post, I removed all the scrap left by SD 2007 and everything went back to normal.
The only lesson i had in this is to only work with copies when working with SD 2007, and basics are often the best way to go.
Again, thanks Jbenisek, and like you said, this guy who set up this should be shot !!!
Saturday, June 14, 2008 10:05 PM -
User540845612 posted
Hi, I had the same problem as the original poster, I made the mistake of opening the website with FrontPage, removed the front page extensions and it all worked. Thanks for the pointers
Monday, June 23, 2008 6:02 AM -
User-813426089 posted
), then delete an unknown folder created by sharepoint, namely vti_cnf from all the folders and sub-folders in your web application, the error disappears.thnks worked for me
Tuesday, July 8, 2008 6:38 AM -
User-333515445 posted
Hi Jbenisek,
I am also facing the same error. The error description is as follows:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Data at the root level is invalid. Line 1, position 1.
Source Error:
Line 1: <browsers> Line 2: <browser ID="Safari2" parentID="Safari1Plus"> Line 3: <controlAdapters>
Source File: /App_Browsers/compat.browser Line: 1
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
When i open the file Compat.browser i m getting the following piece of info
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|13 Oct 2006 23:58:44 -0000
vti_extenderversion:SR|12.0.0.4518
vti_cacheddtm:TX|13 Oct 2006 23:58:44 -0000
vti_filesize:IR|22237
vti_backlinkinfo:VX|
I have no clue abt the above info .
There are no files or directories in the _vti_pvt folder there are no sub folders or any new directories in it .
Please help me
Tuesday, May 5, 2009 8:21 AM -
User-1097017955 posted
Hi,
I had a same problem while calling SP (below) :
ALTER PROCEDURE dbo.[usp ATI SearchStudent V1]
@AcademicDetails NVARCHAR(20),
@FirstName NVARCHAR(20),
@MiddleName NVARCHAR(20),
@LastName NVARCHAR(20),
@Result XML OUTPUT
AS
BEGIN
DECLARE @sSQL VARCHAR(8000)
DECLARE @sCondition NVARCHAR(20)
SET @sCondition = ' WHERE '
SET @sSQL = '(SELECT StudentID,
AcademicDetails,
FirstName as "PersonalDetails/FirstName",
MiddleName as "PersonalDetails/MiddleName",
LastName as "PersonalDetails/LastName" FROM tb_StudentInfo'
IF(@AcademicDetails <> '')
BEGIN
SET @sSQL = @sSQL + @sCondition + ' AcademicDetails = ''' + @AcademicDetails + ''''
SET @sCondition = ' AND '
END
IF(@FirstName <> '')
BEGIN
SET @sSQL = @sSQL + @sCondition + ' FirstName = ''' + @FirstName + ''''
SET @sCondition = ' AND '
END
IF(@MiddleName <> '')
BEGIN
SET @sSQL = @sSQL + @sCondition + ' MiddleName = ''' + @MiddleName + ''''
SET @sCondition = ' AND '
END
IF(@LastName <> '')
BEGIN
SET @sSQL = @sSQL + @sCondition + ' LastName = ''' + @LastName + ''''
SET @sCondition = ' AND '
END
SET @sSQL = @sSQL + ' FOR XML PATH(''Student''), ROOT(''Sis''), ELEMENTS XSINIL);'
SET @Result = @sSQL
--EXEC SP_EXECUTESQL @Result
ENDStill I am looking for solution.
Wednesday, July 1, 2009 5:42 AM -
User-1097017955 posted
Hi Experts,
Any solution? Please help ASAP.
Thanks.
Wednesday, July 1, 2009 5:42 AM -
User-1097017955 posted
OK Experts,
Here is my new Thread : http://social.msdn.microsoft.com/Forums/en-US/linqtosql/thread/850bf317-d8e9-47b2-b049-89f4078bbb1c?lc=1033.
Where I have my complete problem definition.
Please reply at above post.
Thanks.Tuesday, July 7, 2009 10:12 AM -
User-1389311666 posted
Hi,
Thankyou so much for this solution.
My website has many folders like images and icons etc.
Under each there was _vti_cnf folder and each of them had the malicious web.config file.
Once I deleted all of them, I could publish my website without any problem.
I have a doubt whether the _vti_cnf folder is required at all in the first place for the website to run
Thursday, July 9, 2009 3:59 PM -
User-1097017955 posted
Hi All,
Finally got it!
Please check it : http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/8b1ecb8b-66d1-4b20-92b6-e31172939b7c
Thanks.Friday, July 24, 2009 12:02 PM -
User367643247 posted
that change of a line is all we needed. xmlDoc.Load() does the trick. thanks bunch.
Monday, August 17, 2009 2:40 PM -
User367643247 posted
Just try Xml.Load() function instead of Xml.LoadXml().
this is the answer. perfecto!
Monday, August 17, 2009 2:47 PM -
User-1097017955 posted
Hi dgman,
Thanks for reply.
Please check it out : http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/8b1ecb8b-66d1-4b20-92b6-e31172939b7c
Thanks.
Monday, August 24, 2009 5:32 AM -
User646131475 posted
Thank you! This worked beautifully, even though we run MOSS, not WSS.
it was actually the %webroot%\App_Browsers\_vti_cnf folder that needed to be deleted, but it immediately fixed the problem we'd been having for the past 3 hours or so
Wednesday, September 2, 2009 11:50 AM -
User978107000 posted
Thanks so much, your response fixed my issue that just occurred today. You saved me a lot of time!
Thursday, October 1, 2009 6:03 PM -
User-2093583017 posted
Hi,
I am working on Windows phone App dev and getting similar error msg in Visual Studio. But when i double click on the error it navigates to first line first poisition of .xaml.cs file which is:
using System;
using System.IO;.
.
namespace xyz
{
}
Tried opening .xaml file in web and it complains:
System.Windows.Markup.XamlParseException: The tag 'PhoneApplicationPage' does not exist in XML namespace 'clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone'. Line '2' Position '2'.
.xaml contents:
<phone:PhoneApplicationPage
x:Class="sdkMicrophoneCS.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"...
</phone:PhoneApplicationPage>
I dont see any extra spaces in the .xaml
This error popped up out of nowhere and i am unable to resolve.
TIA.
Tuesday, October 16, 2012 7:01 AM -
User-1777219952 posted
I know this is old, but I've got this error when building a solution with SlowCheetah plugin for transforming my config files.
It turned out that the problem was caused by mixed line endings.
I've removed all space from my config and reformatted it and the error has gone.
Friday, March 27, 2015 12:00 AM -
User-1459483077 posted
<?xml version="1.0" encoding="utf-8" ?>
add extra space after encoding="utf-8" should work. I had same issues, then visual studio gave me a tip to add extra space thereMonday, July 6, 2015 8:05 AM -
User-1106985102 posted
This is an old post, but I just encountered the same error message, and resolved it by ensuring the string I parse as XML does not begin with a BOM marker character.
Monday, October 26, 2015 12:04 PM -
User592922307 posted
This answer helped me.
There was a web config file in the Views folder and there was an issue in the line 2.
Removed the file to resolve the issue..
Friday, September 4, 2020 6:59 PM