velocity localization configuration - struts-config

here my struts configuration
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources"/>
<constant name="struts.locale" value="ms_MY" />
<constant name="struts.multipart.maxSize" value="200097152" />
this configuration for *.properties
but for *.vm i dont know how to configure it.
please help me.

Related

Add Exception To URL Rewrite And IIS Server

I have my first IIS Server set up and running. And I have successfully configured the URL Rewrite add on. It works perfectly for all incoming requests. How ever I want to exclude one additional website that runs on the same IIS server. Can someone teach me how to do this?
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="^(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<serverVariables>
<set name="HTTP_REFERER" value="{HTTP_ACCEPT_ENCODING}" />
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
<action type="Rewrite" url="http://working.backendserver:4588/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Base, Form, Img" pattern="^http(s)?://working.backendserver:4588/(.*)" />
<action type="Rewrite" value="http{R:1}://working.inbound.url.com/{R:2}" />
</rule>
<rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding">
<match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
<action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
<preCondition name="NeedsRestoringAcceptEncoding">
<add input="{RESPONSE_CONTENT_TYPE}" pattern=".+" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
enter code here

Android Wear companion activity gear does not show up in watch face

I wanted to provide a Companion Configuration Activity for my Android Wear watch face. I have already build the app that has all the configuration and can communicate directly with the watch face, but I can only launch it from the launcher as app, but the gear does not show up in the watch face section of Android Wear app! Can I allow user to configure the watch face via companion app and also via Google Android Wear app?
This is how I declare my activity in phone module:
<activity
android:name=".Main"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<data android:mimeType="image/*"></data>
</intent-filter>
</activity>
On the watch part, I added in:
<meta-data
android:name=
"com.google.android.wearable.watchface.companionConfigurationAction"
android:value=
"virtualgs.photowatch.Main" />
<meta-data
android:name=
"com.google.android.wearable.watchface.wearableConfigurationAction"
android:value=
"virtualgs.photowatch.Main" />
And the result is the same - no gear shown on the Android Wear app.
Try something like this:
Phone Manifest:
<intent-filter>
<action android:name="com.virtualgs.photowatch.MAIN_CONFIG" />
<category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Watch Manifest:
<meta-data
android:name="com.google.android.wearable.watchface.companionConfigurationAction"
android:value="com.virtualgs.photowatch.MAIN_CONFIG" />
I think the intent action in the phone manifest has to be the same as the meta-data value in the watch manifest to work.
I think this is the correct answer about XML file config:
<activity
android:name=".DigitalWatchFaceWearableConfigActivity"
android:label="#string/digital_config_name">
<intent-filter>
<action android:name=
"com.example.android.wearable.watchface.CONFIG_DIGITAL" />
<category android:name=
"com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
As well as having the activity defined in the phone module, you need to reference it in the wear module as part of the declaration of your watch face service like this:
<service
android:name=".MyWatchFaceService" ... />
<!-- companion configuration activity -->
<meta-data
android:name=
"com.google.android.wearable.watchface.companionConfigurationAction"
android:value=
"com.my.watchface.CompanionConfigurationActivity" />
<!-- wearable configuration activity -->
<meta-data
android:name=
"com.google.android.wearable.watchface.wearableConfigurationAction"
android:value=
"com.my.watchface.WearableConfigurationActivity" />
...
Replacing com.my.watchface.CompanionConfigurationActivity and com.my.watchface.WearableConfigurationActivity with the fully qualified names of the configuration activities in the wear and phone modules respectively.

ServiceStack 4 Razor: no intellisense in Visual Studio 2013 with update 2

I am running a Asp.Net Host (ServiceStack.Host.AspNet 4.0.30.0) - ServiceStack 4.0.30.0 project with Razor.
.Net Framework Target: 4.5.1
The project compiles fine, but I am not getting any intellisense in my Razor Views using Visual Studio 2013 with Update 2.
Any ideas on how to get intellisense to work in the ServiceStack Razor views?
My machine has MVC 4 and 5 installed as well.
Here is also a copy of my web.config...
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
</sectionGroup>
</configSections>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5.1" />
</system.Web>
-->
<system.web>
<httpRuntime />
<compilation targetFramework="4.5.1" debug="true">
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders></compilation>
<pages controlRenderingCompatibilityVersion="4.0" />
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers></system.web>
<system.web.webPages.razor>
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="windows_consumer81_demo.Models" />
<add namespace="windows_consumer81_demo.Models.Scenario" />
<add namespace="windows_consumer81_demo.Localization" />
<add namespace="System" />
<add namespace="ServiceStack" />
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="windows_consumer81_demo" />
</namespaces>
</pages>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
</system.web.webPages.razor>
<appSettings>
<add key="DebugMode" value="true" />
<add key="unsupportedRedirect" value="unsupported.html" />
<add key="vs:EnableBrowserLink" value="false" />
<add key="webPages:Enabled" value="false" /></appSettings>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</configuration>
I guess the way it's supposed to work is that all the namespaces you add in web.config should have IntelliSense:
<system.web.webPages.razor>
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="YourNameSpaceHere" />
<add namespace="SomeServiceStackNameSpace" />
. . .
Then in the .cshtml file you'd add:
#inherits ViewPage<YourModelClassName>
Unfortunately this doesn't always work. It compiles, but you don't get IntelliSense.
However there is a fix:
In your .cshtml file just type out the full namespace:
#inherits ServiceStack.Razor.ViewPage<Full.Namespace.Of.Your.Model.Class>
If you're using other classes, just add:
#using MyServer.ServiceInterface;
#using MyServer.ServiceModel;
Another trick I recommend is to strongly type your #Model object. Right there at the top, after the #Inherits ViewPage<...> stuff add:
#{
Your.Class.Name TypedModel = Model;
}
Feel free to rename TypedModel to something better.

How Can I Secure HTML Files that are Created Dynamically in My ASP.NET 4 Web App?

I am running an ASP.NET 4 application on a Windows 8 R2 server with IIS 7. The application dynamically creates HTML files in a sub-directory "Reports" within the app's root directory. I am attempting to secure these files using the already existing Forms Authentication by making the following changes to the web.config file:
Added these four lines to the <compilation> section:
<buildProviders><br />
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" /> <br />
<add extension=".htm" type="System.Web.Compilation.PageBuildProvider" /> <br />
</buildProviders> <br />
Added these four lines to the <system.web> section:
<httpHandlers><br />
<add verb="*" path="*.htm" type="System.Web.UI.PageHandlerFactory" /><br />
<add verb="*" path="*.html" type="System.Web.UI.PageHandlerFactory" /><br />
</httpHandlers><br />
Tried both of the following
"<handlers>" in the "<system.webServer>" section:<br />
<handlers><br />
<add name="HTML" path="*.html" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" /><br />
<add name="HTM" path="*.htm" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" /><br />
</handlers><br />
and
<handlers><br />
<add name="HtmlHandler-Integrated" path="*.html" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" requireAccess="Script" preCondition="integratedMode" modules="ManagedPipelineHandler" /><br />
<add name="HtmHandler-Integrated" path="*.htm" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" requireAccess="Script" preCondition="integratedMode" modules="ManagedPipelineHandler" /><br />
</handlers><br /><br />
Finally, I added a <location> tag to specify the "role-based" security for the folder:
<br />
<location path="Reports"><br />
<system.web><br />
<authorization><br />
<allow roles="Administrator, Base User" /><br />
<deny users="*" /><br />
</authorization><br />
</system.web><br />
</location><br /><br />
These settings work fine for non-authenticated users, but produce the error "The file '....htm' has not been pre-compiled, and cannot be requested." for the HTML files that are dynamically created from the application.
What other changes are necessary to protect these "html" files from non-authenticated users?
Thanks!

Hourly log4net RollingFileAppender

Is it possible to configure log4net to roll files each hour? If not - any hints on how to override RollingFileAppender with required functionality to make HourlyRollingFileAppender?
Yes: set the datePattern element's value to "yyyyMMdd-HH"
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logfile" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd-HH" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
Ref: log4net Config Examples.