I am trying to retrieve query string values from a url. And the app should be a silverlight app.
For Eg: The sample URL might look like http://<hostname>/silverlightApp/Default.aspx?S=Name|address|title|sal|...
I should be able to take the query string and built a Silverlight UI.
Can this be done or Silverlight is not a good candidate for this type.
There are multiple ways you can do this. In the hosting page, you can pull out query string values using Request.QueryString, and then pass them to Silverlight using the initParams tag, i.e.:
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
width="100%" height="100%">
<param name="source" value="/ClientBin/MyApplication.xap" />
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40620.0" />
<param name="autoUpgrade" value="true" />
<param name="windowless" value="true" />
<param name="initParams" value="<%=InitParameters %>" />
<param name="splashScreenSource" value="<%=SplashScreenSource %>" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40620.0" style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight"
style="border-style: none" />
</a>
</object>
Or from within the Silverlight application itself, you can grab the querystring and other parts of the URI by using HtmlPage.Document.documentUri, e.g.:
Uri uri = HtmlPage.Document.DocumentUri;
And once you've got the actual querystring, you can parse it using regular expressions, or whatever your poison of choice happens to be.
HTH.
See System.Web.HttpUtility.ParseQueryString() Method, which parses a query string into a NameValueCollection.
[Later] Sorry, the Silverlight runtime seems to be without the System.Web namespace.
See system.Uri.Query in the System namespace provided with Silverlight runtime.
The Query property contains any query information included in the URI. Query information is separated from the path information by a question mark (?) and continues to the end of the URI. The query information returned includes the leading question mark.
The query information is escaped according to RFC 3986.
The following example writes the query ?date= today to the console.
Uri baseUri = new Uri ("http://www.contoso.com/");
Uri myUri = new Uri (baseUri, "catalog/shownew.htm?date=today");
outputBlock.Text += "Uri.Query: ";
outputBlock.Text += myUri.Query;
outputBlock.Text += "\n";
Related
I have an ADLS with images that I want to display on my website.
I want to expose them through APIM. I am sending the image name and SAS token in the request which I re-write in the actual backend request with the right folder structure.
The policy -
<policies>
<inbound>
<set-variable name="BlobName" value="#(context.Request.Url.Query.GetValueOrDefault("BlobName"))" />
<set-variable name="sasToken" value="#(System.Net.WebUtility.UrlDecode(context.Request.Url.Query.GetValueOrDefault("sasToken")))" />
<base />
<set-backend-service base-url="#{
string blobName = context.Variables.GetValueOrDefault<string>("BlobName");
string sasToken = context.Variables.GetValueOrDefault<string>("sasToken");
return String.Format("https://myadls.blob.core.windows.net/UserImages/Images/{0}?{1}",blobName,sasToken);
}" />
<authentication-managed-identity resource="https://storage.azure.com/" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
The SAS token - sv=2020-08-04&st=2022-02-24T04%3A17%3A53Z&se=2022-02-24T06%3A17%3A53Z&sr=c&sp=r&sig=5B6IUrj9VSh7oZSHAOKQK7fsWLun%2B%2BL7v0o1gQJHxvU%3D
Since the SAS token and '&' sign, the sasToken string is getting truncated to 'sv=2020-08-04'
As you can see in the policy I tried to encode the SAS in c# as
System.Net.WebUtility.UrlEncode(dataLakeSasBuilder.ToSasQueryParameters(sharedKeyCredential).ToString());
But, the System.Net.WebUtility.UrlDecode did not decode the value.
Thanks in advance.
I found that encoding it in the code and decoding the string in the policy is solving this
Encoding.UTF8.GetString(Convert.FromBase64String(context.Request.Url.Query.GetValueOrDefault("sasToken")))
I am trying to add file upload to my Spring Webflog form processing. As far as the form enctype is not set to multipart/form-data, form submition works just fine. But after I added enctype="multipart/form-data" to my Spring form, this Exception occurs:
java.lang.IllegalStateException: A flow execution action URL can only be obtained in a RenderRequest or a ResourceRequest
at org.springframework.webflow.context.portlet.PortletExternalContext.getFlowExecutionUrl(PortletExternalContext.java:215)
at org.springframework.webflow.engine.impl.RequestControlContextImpl.getFlowExecutionUrl(RequestControlContextImpl.java:178)
at org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:189)
at org.springframework.webflow.engine.ViewState.render(ViewState.java:293)
at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:242)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:220)
at org.springframework.webflow.engine.Flow.resume(Flow.java:537)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.portlet.FlowHandlerAdapter.handleAction(FlowHandlerAdapter.java:161)
at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:670)
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:520)
at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:461)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:71)
I have added CommonsMultipartResolver to my spring context:
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- Limit uploads to one byte smaller than the server is allowed to handle -->
<property name="maxUploadSize" value="100000" />
</bean>
and have commons-fileupload.jar in my pom.xml:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
My JSP looks like this:
<portlet:actionURL var="processFormAction" >
<portlet:param name="execution" value="${flowExecutionKey}"/>
</portlet:actionURL>
<form:form action="${processFormAction}" modelAttribute="customerModel" enctype="multipart/form-data" method="post" >
<form:input path="firstName" cssClass="input-size-1 valid-required" />
<form:input path="lastName" cssClass="input-size-1 valid-required" />
<input name="avatar" id="avatar" type="file"/>
<input type="submit" name="_eventId_submit" id="send" value="Submit"/>
</form:form>
My flow.xml definition:
<view-state id="state1" model="customerModel">
...
<transition on="submit" to="submitFormActions"/>
</view-state>
<action-state id="submitFormActions">
<evaluate expression="portletAction.processForm(customerModel, flowRequestContext)" />
<transition on="success" to="state2"/>
<transition on="error" to="state1" />
</action-state>
The model object:
public class CustomerModel implements Serializable{
private String firstName;
private String lastName;
private MutlipartFile avatar;
...
//public getters and setters
}
Any thoughts what could be wrong? As I said, without enctype="multipart/form-data" the form processing works well.
Thanks
You are using org.springframework.web.multipart.commons.CommonsMultipartResolver which is not aware about the portlet context.
You need to change CommonsMultipartResolver to:
<bean id="portletMultipartResolver"
class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="100000"/>
</bean>
Also, for this bean to be recognised by DispatcherPortlet, you need to define this bean id as mentioned above. The doc says:
Any configured PortletMultipartResolver bean must have the following id (or name): "portletMultipartResolver".
If you have defined your PortletMultipartResolver with any other name, then the DispatcherPortlet will not
find your PortletMultipartResolver, and consequently no multipart support will be in effect.
I'm using silverlight3 and vb.net..I want to pass the value from Default.aspx to my App or Main page. I wrote the code in my default.aspx page which it is returning the local ip address of the client System, I would like that same address to be used in my silverlight pages.
VB code
Dim clientIPAddress = System.Net.Dns
.GetHostAddresses(strHostName).GetValue(0).ToString()
This clientIPAddress will get the local ip of the client which is like 192.168.1.12. Now i want this value to be passed to my main page.
Please any one help to pass this value from default.aspx to my main page.
Thanks
Your default.aspx page will have an <object> tag where the Silverlight plugin is loaded. You can added a <param name="initParams value="clientID=192.168.1.12"> so it looks something like:-
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/Silverlight3App.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40818.0" />
<param name="autoUpgrade" value="true" />
<param name="initParams` value="clientID=192.168.1.12"`>
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</form>
Except of course you wouldn't hardcode the IP address but you'd inject that with some VB.NET code (I don't do VB.NET).
The initParams parameter is a set of name=value pairs that are exposed in Silverlight as a IDictionary(Of String, String). You can get this dictionary from the Application Startup event arguments or from Application.Current.Host.InitParams.
I am provisioning a publishing page as part of a feature and placing a single list view web part on the page (see code below). This all works perfectly sp far.
<Elements>
<Module>
<File Path="default.aspx" Url="BulletinBoard.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
<Property Name="Title" Value="Bulletin Board" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/ListNewsletterStyle.aspx" />
<Property Name="ContentType" Value="Page" />
<Property Name="PublishingPageImage" Value="" />
<View List="Lists/BulletinBoard" BaseViewID="2" WebPartZoneID="Main" WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title">Active Announcements</property>
<property name="ChromeType">None</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</View>
</File>
</Module>
</Elements>
The only problem is that each time I redeploy my feature through Visual Studio, the list view web part is duplicated (i.e. another one is added to the web part zone).
This problem only appears to affect web parts with the <View ...> tag. Web parts provisioned with the <AllUsersWebPart ...> tag are not being duplicated.
How do I prevent this?
You can add a feature receiver and add the webpart if it not alreay exists in stead of adding the webpart in XML.
What do you mean by tag?
Check out this blog entry from Waldek Mastykarz. It has the C# code below that should be similar to what you are looking for.
using (SPSite site = new SPSite("http://sharepoint"))
{
SPList list = site.GetCatalog(SPListTemplateType.MasterPageCatalog);
SPListItemCollection items = list.Items;
List<string> webParts = new List<string>();
// find the right Page Layout
foreach (SPListItem item in items)
{
if (item.Name.Equals("CustomPageLayout.aspx",
StringComparison.CurrentCultureIgnoreCase))
{
SPFile file = item.File;
// get the Web Part Manager for the Page Layout
SPLimitedWebPartManager wpm =
file.GetLimitedWebPartManager(PersonalizationScope.Shared);
// iterate through all Web Parts and remove duplicates
while (wpm.WebParts.Count > 0)
{
StringBuilder sb = new StringBuilder();
XmlWriterSettings xws = new XmlWriterSettings();
xws.OmitXmlDeclaration = true;
XmlWriter xw = XmlWriter.Create(sb, xws);
System.Web.UI.WebControls.WebParts.WebPart wp =
wpm.WebParts[0];
wpm.ExportWebPart(wp, xw);
xw.Flush();
string md5Hash = getMd5Hash(sb.ToString());
if (webParts.Contains(md5Hash))
wpm.DeleteWebPart(wp);
else
webParts.Add(md5Hash);
}
}
}
}
Note to SharePoint 2013 users. You should add ReplaceContent=True to the tag. The duplicate webpart issue will be resolved.
I have a SWF file and I am trying to embed it into an HTML.
I used the following code:
<object width="704" height="440">
<param name="movie" value="http://riskgames.ist.psu.edu/CyberLinkIT.swf"></param>
<embed src="http://riskgames.ist.psu.edu/CyberLinkIT.swf" type="application/x-shockwave-flash" menu="false" width="704" height="440">
</embed>
</object>
If you go to http://miaojiang.net/bug.html, you can see the problem. The button is blinking and all invisible text field are displayed.
However, if I open the swf file directly, there is no problem.
Any idea?
This is your problem.
SecurityError: Error #2149: Security sandbox violation: https://riskgames.ist.psu.edu/CyberLinkIT.swf cannot make fscommand calls to http://miaojiang.net/bug.html (allowScriptAccess is ).
at FSCommand$/_fscommand()
at global/flash.system::fscommand()
at CyberLinkIT_fla::MainTimeline/frame1()
<object width="704" height="440">
<param name="movie" value="http://riskgames.ist.psu.edu/CyberLinkIT.swf"></param>
<param name="AllowScriptAccess" value="always"></param>
<embed src="http://riskgames.ist.psu.edu/CyberLinkIT.swf" type="application/x-shockwave-flash" menu="false" width="704" height="440" AllowScriptAccess="always">
</embed>
</object>