What I have “Tried”
1. Adding reference to , System.Core, System.Xml.Linq, System.Data.Linq by right clicking on my website root as well as in individual pages.
-
By adding assembly in web.config as shown below,
<configuration> <connectionStrings> <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\PayrollSystem_DB.mdb" providerName="System.Data.OleDb"/> </connectionStrings> <location path="~/Styles/StyleSheet.css"> <system.web> <compilation debug="true"> <assemblies> <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> </compilation> <authentication mode="Forms"> <forms loginUrl="~/Login/frmLogin.aspx"/> </authentication> <authorization> <deny users="?"/> </authorization> </system.web> </location> </configuration>
It was working fine in the project earlier today. I ran into first web.config issue when I added
<authentication> and <authorization>
tags my CSS stop working on the login page. Then I added Location tag as shown above and it fixed my css for login page but then I started getting this Linq error on every page.
I searched online it was advised it is web.config issue so I should add the reference for System.core assembly in the web.config file which I did but still same issue.
R00T CaUsE
Adding
tag with the code shown in above question would make any anonymous user from accessing any page other than Login, as each request will be redirected to LogIn Page with no other content allowed from server including basic CSS.
Suggested solution 1 on the web was to add
tag which works for css but causes issue with the System.Linq.
Here is the solution for the StUpIdItY. First of since nothing was working I saved web.config contents and deleted web.config and recreated from scratch as follows.
Step1
This first step took Linq errors away.
Step 2
Problem with this approach is since I am using external CSS file it will not apply to LOGIN page as
will block any anon user.
You can still use CSS by having css in separate folder and adding another web.config file under the folder where your external CSS is. In my case my css file was, StyleSheet.css under Styles folder. So I just added web.config there as follows.
Now my css is working fine, as well as I can use LogIn page and Linq.
Thanks to MICROSOFT for wasting my time on these issues but I hope I can save frustrations to many in the future.