I am using some common function in Razor-Mediator templating,
As per the Razor doc, we can create a helper file and can define all the common function there.
<razor.mediator cacheTime="60" extractBinaries="true" adminUser="XXX\pgupta">
<namespaces>
<add namespace="System.Linq" />
<add namespace="Tridion.Extensions.Mediators.Razor.Templating" />
</namespaces>
<assemblies>
<!-- <add assembly="C:\Program Files\Assembly\Test.Sample.dll" /> -->
<!--<add assembly="RazorSample.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=60ad7434f03dfcdc" />-->
</assemblies>
<imports>
<!--<add import="tcm:4-21631-2048" />-->
<add import="/webdav/04 Vanilla Layout/Building Blocks/System/Template Building Blocks/Razor/razor.cshtml" />
<add import="C:\Program Files (x86)\Tridion\Razor Mediator\helper.cshtml" />
<!-- <add import="tcm:120-2200-2048" publications="020 Design Master,030 Another Web Design" />-->
</imports>
<importSettings includeConfigWhereUsed="true" includeImportWhereUsed="true" replaceRelativePaths="false" />
</razor.mediator>
i am successfully import these all function when I defined the physical path in the config file.
But, its not working when I defined the wevDAV URL in the config file,
Could any one please help me on this?
I see spaces in your webdav path - is it like this or do you have %20 and SO is stripping them out?
I usually write a small VBScript Page Template and put use this code to get the webdav URL:
[%
dim uri, item
uri = "tcm:0-0-0" ' update this uri and use the item in the parent repository
set item = TDSE.GeTObject(uri, 1)
WriteOut item.info.WebdavUrl
%]
Otherwise, the Razor 1.3 Mediator added Where Used functionality compatibility and this could be causing some issues. The source code was updated to 1.31 but a compiled version of it is not on the Google Code Downloads. You can grab the source and compile yourself to use the latest version: http://code.google.com/p/razor-mediator-4-tridion/source/list
Related
I have been digging for hours and keep coming up with information about .NET Core, yet hardly anything about .NET 4.7 full framework. I figured out how to add User Secrets to the main project of my Web API solution. I get the basic secrets.xml file where I need to to either store my database username and password or my connection string. Every post I find talks about the changes you need to make to web.config. However nothing shows what to do with my connection string, how to format it, in the secrets.xml file. I could create a name/value pair but that does not seem to do anything, my app cannot connect to the database.
I have this in my Web.config:
<configBuilders>
<builders>
<add name="Secrets" userSecretsId="5c65f7eb-a7e1-46cc-bff4-a526678005f2" type="Microsoft.Configuration.ConfigurationBuilders.UserSecretsConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.UserSecrets, Version=1.0.0.0, Culture=neutral" /></builders>
</configBuilders>
<connectionStrings configBuilders="Secrets">
<add name="ShopAPDbConnectionString" connectionString="" providerName="System.Data.SqlClient" />
</connectionStrings>
My secrets.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<root>
<secrets ver="1.0">
<secret name="ShopAPDbConnectionString" value="Server=SQLDEV01;Database=ShopAP; Integrated Security=True;" />
</secrets>
</root>
How do I properly format and get this to work?
Here is what I was able to get to work based on https://github.com/aspnet/MicrosoftConfigurationBuilders
Web.config
<configuration>
<configSections>
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
</configSections>
<configBuilders>
<builders>
<add name="Secrets" userSecretsFile="~/../../../SecretsTest/secrets.xml" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.UserSecretsConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.UserSecrets, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="Json" jsonFile="${JSONConfigFileB}" optional="true" type="Microsoft.Configuration.ConfigurationBuilders.SimpleJsonConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Json, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</builders>
</configBuilders>
<!--...-->
<appSettings configBuilders="Secrets">
<!--...-->
</appSettings>
<!--...-->
<connectionStrings configBuilders="Json">
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="dummy.value.required" />
</connectionStrings>
<!--...-->
</configuration>
secrets.xml
<?xml version="1.0" encoding="utf-8" ?>
<root>
<secrets ver="1.0">
<secret name="usersecret1" value="dogodog" />
<secret name="usersecret2" value="secretbar" />
<secret name="JSONConfigFileB" value="C://Users//xxx//Documents//xxx//xxx//SecretsTest//settings.json" />
</secrets>
</root>
settings.json
{
"DefaultConnection": "Server=666.66.666.6;Database=BigToe;User ID=FireBall;Password=BunniesAreSoft",
}
Both your files look fine - pretty much exactly the same as mine.
How did you create your secrets file? Did you use right-click on the Web project and Manage User Secrets?
That will create a file in a folder location in %APPDATA% that should be picked up when you hit F5 in Visual Studio (Debug > Start Debugging). However, it will not be seen by IIS if you compile and then browse to localhost. Even if you change the App Pool Identity in inetmgr to run under your account, and set Load User Profile - it still will not find it.
To find the correct location for the secrets for this case, run your web app and obtain the result of
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
and copy the secrets file into the matching sub-folder Microsoft\UserSecrets\(guid)\
e.g.
C:\Windows\System32\config\systemprofile\AppData\Roaming\Microsoft\UserSecrets\5c65f7eb-a7e1-46cc-bff4-a526678005f2\secrets.xml
you may need to one-off obtain access in Explorer, and create the UserSecrets folder and below.
Remember to update both copies if you edit it in future.
Make sure the only file in your UserSecrets folder (C:\Users...\UserSecrets{guid}) is the secrets.xml file. I was messing around and had a secrets.json file in there (along with the secrets.xml file) and it wouldn't load my secrets.xml file. After I removed the json file, it worked fine.
I am attempting to do the same thing, but unfortunately I think this is only for appSettings when it comes to .Net Framework/Web.config.
I'm using BitcoinLib in my ASP.NET Core (v2) Web Api project. However, whenever I try to instantiate the service:
var bitcoinService = new BitcoinLib.Services.Coins.Bitcoin
.BitcoinService(appSettings.BitcoinSettings.ServerUrl,
appSettings.BitcoinSettings.Username,
appSettings.BitcoinSettings.Password,
appSettings.BitcoinSettings.WalletPassword);
I get the error:
One or more required parameters, as defined in CoinParameters, were not found in the configuration file!
I verified that the values that are being passed in are not null and correct, I've even added the settings to my web.config:
<configuration>
<appSettings>
<add key="RpcRequestTimeoutInSeconds" value="60" />
<add key="Bitcoin_DaemonUrl" value="http://localhost:18332" />
<add key="Bitcoin_DaemonUrl_Testnet" value="http://localhost:18332" />
<add key="Bitcoin_WalletPassword" value="X" />
<add key="Bitcoin_RpcUsername" value="X" />
<add key="Bitcoin_RpcPassword" value="X" />
</appSettings>
...
Nothing works... do I need to fork this thing and remove that IgnoreConfigFiles check or am I doing something wrong here?
The exception showing was a misdirection... the actual problem was with rpcRequestTimeoutInSeconds. The library needs to have an overload like this:
BitcoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds)
It looks like the NuGet package is missing it? As I can see it in the code...
More info here:
https://github.com/GeorgeKimionis/BitcoinLib/issues/42
I did create a .NET Core compatible one here:
https://github.com/SaganMarketing/BitcoinLib
You can get a package here:
https://www.myget.org/feed/saganmarketing/package/nuget/BitcoinLib
I have just deployed a new MVC3 application, and after some efforts on my hosting provider's side, MVC3 seems to be running OK, but now I get the following compilation error before anything on the site loads:
CS0246: The type or namespace name 'Telerik' could not be found (are you missing a using directive or an assembly reference?)
This occurs in web.config on the following line:
<add namespace="Telerik.Web.Mvc.UI" />
I know the DLL is present in the bin folder on the host, so I'm a bit lost as to what else could be wrong.
If you are using Razor this line:
<add namespace="Telerik.Web.Mvc.UI" />
must occur in ~/Views/web.config and not in ~/web.config. Could this be your case?
Like this:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Telerik.Web.Mvc.UI" />
</namespaces>
</pages>
</system.web.webPages.razor>
http://www.telerik.com/community/forums/aspnet-mvc/general/issue-with-telerik-mvc3-razor-content-appearing-at-the-top.aspx
Read the reply by Mike Kidder. Sorry for linking another forum, I know that's annoying but I'd rather give credit where due.
Two big takeaways when converting to Razor syntax:
1) Use #( .... ) when outputting html, not #{ .... ;}
- wrap the code for Telerik controls in parentheses, not brackets
- using brackets, you're essentially telling Razor to execute a method. You won't get any output
2) Remove the ".Render()" method for any Telerik controls. Not used in Razor.
You have to set Copy Local to true for the assemblies you have referenced. In your case expand References, select the assembly, press F4 to open the properties and set Copy Local to true. The assembly most probably is installed in the GAC so when you add a reference to it by default Copy Local is false.
it might be in the bin folder but, since you didn't mention this, did you actually add reference to the file in the project? after adding the reference to the dll, it should build correctly
When the following profile section is in my web.config, the first page request fail with FileNotFoundException and a bunch of error coming from the compiler (from the look of the stack trace). When the properties section is removed, everything works again (until I try to reference something from the Profile of course). The rest of the website is pre-compiled, assembly per page, not-updatable.
The problem has only been reproduced on one machine-- the same build worked on other highly similar machines.
Am I missing anything obvious?
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider"
connectionStringName="ConnectionString"
applicationName="OIWebApps"
type="System.Web.Profile.SqlProfileProvider"/>
</providers>
<properties>
<group name="UI">
<add name="MasterPage" defaultValue="Horizontal.master"/>
<add name="Theme" defaultValue="Default"/>
<add name="IsSessionWarningEnabled" defaultValue="True" type="System.Boolean"/>
<add name="UseTelerikMultilineTextBoxes" defaultValue="True" type="System.Boolean"/>
<add name="FontSize" defaultValue="Smaller" type="System.String"/>
</group>
</properties>
</profile>
I see "UseTelereikMultilineTextBoxes". Could it be that a file needed for Telerik is missing on this machine?
It failed to compile because of a missing native .dll It was extremely hard to identify because the page that was executing didn't directly use the .net dll that depended on the missing native .dll, and even more confusingly, only some pages raised the compile error instead of being raised on all pages.
I'm trying to map requests for classic asp pages to be handled by .net, so that it runs through a custom httpmodule.
In IIS I have remapped asp requests to aspnet_isapi.dll - I'm sure I've done this bit right
Now in my test app I am getting this error:
Server Error in '/TestASPRedirect' Application.
--------------------------------------------------------------------------------
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.asp' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /testaspredirect/test.asp
Searching online for this error shows a load of people having problems with cassini, but this is not really relevant, I am testing this on both IIS 5.1 on XP dev machine, and have tested on IIS6 also getting the same error.
I have followed instructions for adding and registering a httphandler (see http://support.microsoft.com/default.aspx?scid=kb;en-us;Q308001), but I don't know what to put in the ProcessRequest routine to ensure the request gets passed on. What is the default .net httphandler, can I just map to this in web.config?: so something like:
<httpHandlers>
<add verb="*" path="*.asp" type="standard.nethttphandler"/>
</httpHandlers>
How do I tell asp.net that it needs to pass ASP requests on and not block?
Actually you are only one step far from the success. Adding following section to your Local website(or virtual directory) web.config file:
<configuration>
...
<system.web>
<compilation>
<buildProviders>
<add extension=".asp" type="System.Web.Compilation.PageBuildProvider"/>
</buildProviders>
</compilation>
<httpHandlers>
<add path="*.asp" verb="*" type="System.Web.UI.PageHandlerFactory" validate="true"/>
</httpHandlers>
</system.web>
It looks like the .asp extension is mapped to the HttpForbiddenHandler.
If you're using ASP.NET 1.1 then open the following file:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG\machine.config
If you're using ASP.NET 2.0 then open this file:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config
Search for "path="*.asp"", then comment out that line. It'll like something like:
<!-- machine.config/ASP.NET 1.1-->
<add path="*.asp" verb="*"
type="System.Web.HttpForbiddenHandler"/>`
<!-- web.config/ASP.NET 2.0-->
<add path="*.asp" verb="*"
type="System.Web.HttpForbiddenHandler" validate="true"/>`
Locate the below file:
C:\WINDOWS\MICROSOFT.NET\FRAMEWORK\<FramworkVersion>\Config\web.config
where <FramworkVersion> is folder name:
open it in an XML editor .. (even notepad is fine)
and add below line :
<add path="*.asp" verb="*" type="System.Web.UI.PageHandlerFactory" validate="True"/>
under below XPath:
configuration/system.web/httpHandlers
replace the existing one!
Add below line:
<add extension=".asp" type="System.Web.Compilation.PageBuildProvider"/>
under below XPath:
/configuration/system.web/compilation/buildProviders
Worked like gem for me :)