ReplacableToken_ when using web.config transform? - web-config

I have a web.config with 2 transforms - for debug and release.
web.config:
<connectionStrings>
<clear />
<add name="StrName" connectionString="data source=.\sqlexpress;User Id=sa;Password=pass;Database=SocialBot;"
providerName="System.Data.SqlClient" />
</connectionStrings>
I just copied the example given and replaced the name with StrName. I end up with :
<add name="StrName" connectionString="$(ReplacableToken_SocialBotConnectionString-Web.config Connection String_0)"
providerName="System.Data.SqlClient" />
What the hell is ReplacableToken_ ?
I have another project and it works with no problem there.

If, like me, you're running up against this problem while trying to automate your build process using msbuild from the command line. Specifically, the parameter you need to set is:
/p:AutoParameterizationWebConfigConnectionStrings=False
This is most likely what VS is doing on your behalf when you publish to the filesystem

If you want to build with Visual Studio 2010, add the following line to your configuration PropertyGroup in your .csproj:
<AutoParameterizationWebConfigConnectionStrings>False</AutoParameterizationWebConfigConnectionStrings>
More details here:
How to get rid of "$(ReplacableToken...)" in web.config completely

Related

Reverse Poco only Generating initial comment block

I'm trying to generate models from an existing database using the Reverse POCO generator. I've not made any changes to the default template file and I've called my connection string "MyDbContext".
<connectionStrings>
<add name="MyDbContext" providerName="System.Data.SqlClient" connectionString="Data Source=xx.xxx.xx.xxx\SQLEXPRESS;Initial Catalog=ZooQ;Persist Security Info=True;User ID=ZooQDev;Password=******;"/>
</connectionStrings>
I've checked the credentials are ok by testing the connection in visual studio, so I know they are right. Only difference to the usual way I do this is that now I'm accessing a VM server on Azure, but I wouldn't think that would be the problem.
I've tried uninstalling and reinstalling the generator, uninstalling and reinstalling Entity Framework, deleting and re-adding the template file and closing and re-opening Visual Studio.

JetBrain Rider , Access denied when using IIS Express with Windows Authentication

I have an enabled Windows Authentication on my projects. When I run it from Rider, it always prompts me "access denied". It's working fine when I run it via Visual Studio.
How can I solve this?
Navigate to: <project>.idea/config/applicationhost.config
Find the tag <authentication> and enable the <windowsAuthentication> tag like so: <windowsAuthentication enabled="true">
Mine looks like this:
<windowsAuthentication enabled="true">
<providers>
<add value="Negotiate" />
<add value="NTLM" />
</providers>
</windowsAuthentication>
Work-in-progress by JetBrains, see issue RIDER-15230
Just to build on #RyanDawkins answer with a GUI equivalent.
Steps
Right-click the Project the web app launches from
Select Properties ...
In the Modal, under Properties > Web there is a checkbox for Windows authentication
Screenshot
This is similar to the Visual Studio way of doing things, it just saves the settings in {SolutionFolder}/.idea/config instead of {SolutionFolder}/.vs/config
In <project>.idea/config/applicationhost.config
I had to do two things:
Set: <windowsAuthentication enabled="true">
Set: <anonymousAuthentication enabled="false">

SQL Server Compact 4.0 code-first with connectionstring specified

I have a simple console application setup and I am trying to get code-first Entity working properly. I've done the basic examples and have set up my classes and context. Once I run my application the database is auto generated and placed in my bin/Debug directory. That's great so at least something works. But now I want to add a SQL Server Compact 4.0 database file (.sdf) to the project and use that instead of the autogenerated database. From what I've read I just need to add a connection string with a name that matches the derived DbContext class.
Below is my app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="StudentContext"
connectionString="Data Source=Database1.sdf"
providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
And this is the error I am receiving when it tries to use the initialize the context.
The inner exception says
Configuration system failed to initialize
I've tried specifying the context directly though the constructor, and still no luck. Hopefully, I am just overlooking something.
(Side note, I grabbed EntityFramework from Nuget and it should be 5.0, yet the appconfig says 4.4? The autogeneration works great so I figured they didnt have anything to do with each other.)
Problem was in my connection string I was pointing to a location that didnt exist. Hence every time I would run the program it would create a file in the bin/debug automatically.
So either specify a direct file path to the sdf file or use |DataDirectory|
connectionString="Data Source=|DataDirectory|Database1.sdf"
Then peak at what your directory is set to. If its not the directory in your application, then you will need to change this manually. But Websites have an App_Data directory that it should point to.
var s = AppDomain.CurrentDomain.GetData("DataDirectory");

AjaxControlToolkit 7.0123 breaks VS2012 Web Application Project

I have an existing VS2012 web application that has been running fine until I added in the latest AjaxControlToolkit (7.0123). Initially, I found that the installation broke the behaviour of the UpdatePanel - whereas before I could refresh a page after an asynchronous post-back without repeating the operation I found that after installation the refresh would repeat the previous operation (I guess the post-back was no longer asynchronous).
I then noticed that, at some time in the past, I had commented out a number of the default JavaScript files that are added to a new ASP.NET Web Forms Application so I tried adding them back in. This resulted in an exception:
'MsAjaxBundle' is not a valid script name. The name must end in
'.js'.
I then tried replacing the default <asp:ScriptManager .../> with <ajaxControlToolkit:ToolkitScriptManager .../> this resulted in a new exception
Could not load file or assembly 'System.Web' or one of its
dependencies. The system cannot find the file specified.
For sanity, I then created a fresh ASP.NET Web Forms Application (VS2012, Update 2) and ran it. No errors. Using "nuget", I then added the AjaxControlToolkit v7.0123 (the latest release). Ran the application again and I get the original exception again:
'MsAjaxBundle' is not a valid script name. The name must end in
'.js'.
Once again, I replaced <asp:ScriptManager .../> with <ajaxControlToolkit:ToolkitScriptManager .../> and once again this results in
Could not load file or assembly 'System.Web' or one of its
dependencies. The system cannot find the file specified.
Can anybody shed any light on what else I need to do to resolve this? I can find no documentation to say anything needs to be changed manually when adding the toolkit.
Thanks,
Answer found at http://stephenwalther.com/archive/2012/09/20/september-2012-release-of-the-ajax-control-toolkit.aspx (always just after posting the question huh)
Replacing <asp:ScriptManager .../> with <ajaxControlToolkit:ToolkitScriptManager .../> is correct
Need to remove reference to MsAjaxBundle
Need to remove Assembly="System.Web" from script references
This fixes the exceptions (both in the new project and the original).
It does not however resolve the problem with the UpdatePanel no longer posting back asynchronously. I will raise this as a new question.
If you are using the April 2013 Release of the Ajax Control Toolkit see Stephen Walther's latest blog post:
http://stephenwalther.com/archive/2013/04/30/april-2013-release-of-the-ajax-control-toolkit.aspx
I was missing the new web.config settings that allow the AjaxFileUpload control to work in the new release
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="42949672" />
<httpHandlers>
<add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</handlers>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967295"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>
When you see this "'MsAjaxBundle' is not a valid script name. The name must end in '.js'."
The Best thing you can do is:
Go to the site Master (Double click on it )
Search for "MsAjaxBundle" or " "
Comment this line eg. <%----%>
Save or compile your program and then run it
Thank God is working by now

CrystalReportViewer does not display Charts

My CrystalReportViewer won't display the charts in my Crystal Report. I get a red X.
I am using C# and MVC. I've read somewhere that I might need a virtual path to the image folder, but I am not really sure what that means as my chart is embedded in the report... Maybe I am missing something. Can anyone elaborate?
OK. I figured it out... MVC, like I said, is processing the route rather than letting the CrystalImageHandler handle it. So here are the steps to make MVC and Crystal ReportViewer display images work.
Read this link and follow the web.config instructions. Make sure all the assemblies point to version 12. You will actually need to install the Crystal Runtime and or Crystal to get the latest assembly versions.
Add this line to your global.asax file to ignore the route of the CrystalImageHandler:
routes.IgnoreRoute("{*allaspx}", new { allaspx = #".*(CrystalImageHandler).*" });
I had a similar problem with crystal reports imbedded with chart / graphs. Using MVC3 framework and crystal report runtime v10
Add the following lines to Web.config
<appSettings>
<!-- For Crystal reports to render dynamic images (eg. charts, graphs)-->
<add key="CrystalImageCleaner-AutoStart" value="true" />
<add key="CrystalImageCleaner-Sleep" value="60000" />
<add key="CrystalImageCleaner-Age" value="120000" />
</appSettings>
<system.web>
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
</system.web>
Add this in the method RegisterRoutes in Globalasax
/*Added for Crystal reports*/
routes.IgnoreRoute("{*allaspx}", new { allaspx = #".*(CrystalImageHandler).*" });
Copy pg32conv.dll and sscsdk80.dll to Windows\System32.
i am also facing same problem while create my crystal report with chart(graphical representation ) , i am unable to get image of chart then
i add some code in web.config file
below the <appSettings></appSettings> tag
we have a tag like
<httpHandlers> </httpHandlers>
check we are having the code in between above taghttphandlers,
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
if it is there then we definetly get image of chart or bar what ever
if it is not there plz add the code like above k
i hope this is useful to all
thanks.