Why does my Azure application still point to default.aspx? - silverlight

I have created a PivotViewer application with an Azure Web role, and it deploys on my local machine perfectly. When I deploy it to azure, the standard default.aspx "My ASP.NET" application is the loaded page. I can not seem to find a solution in all of the tutorials. If I point the browser to http://solution.cloudapp.net/MyAzureStartPage.aspx, I can also find a perfect deployment, but I can't seem to get the proper home page.

Determining which page to load if none is explicitly specified is a function of the web server. Without configuration changes, the web server is never going to expect to look for your custom page.
Can you not simply rename your desired start page default.aspx? That would be the simplest approach.

Add defaultDocument element in your web.config under configuration/system.webServer node. Something like this will get your default page defined:
<defaultDocument enabled="true">
<files>
<add value="MyAzureStartPage.aspx"/>
</files>
</defaultDocument>

Related

How to configure redirects Glassfish4 Maven Webapp

I am developing a WebApp using Glassfish 4. I have a REST backend, developed in JAVA using Jersey, and a AngularJS frontend. All this is contained in a MAVEN Jersey-Quickstart-Webapp.
Now, the problem I have is that when people query the URL for my app:
http://localhost:8080/MyApp/
It works fine, and sends the appropriate index.html to the user. However, if the user types a URL that 'should' be handled by my Apps routing, say like:
http://localhost:8080/MyApp/search
it gives a 404 error. However, this URL can be reached from within in the app if you start from the /MyApp/ route, because the index.html that is served with all the angularJS stuff is able to understand and control the routing.
Essentially the problem I face is that I need to set up the appropriate redirects for all the necessary places that should return the index.html.
So, when I hit any of the following URLs it should send the user the index.html, and let AngularJs figure out the routing
Eg.
http://localhost:8080/MyApp/search ----> index.html
http://localhost:8080/MyApp/results ----> index.html
http://localhost:8080/MyApp/browse ----> index.html
Unfortunately, I am probably being really thick here, but I don't know how to configure the server/webapp to do this. How do I go about doing this? I assume it is fairly obvious/trivial, but I'm pretty new to all this stuff, so go easy on me!
EDIT 1: I've had some good help about using a mod-rewrite or the UrlRewriteFilter but neither of these seems to work for Glassfish4 as far as I can see. Is there an equivalent out there for these that somebody might know of?
Log into glassfish In the Admin Console, expand the Configurations
node. Expand the server-config node. Ignore this step if you are
running a developer domain (a domain that does not have clustering
capability). Expand HTTP Service. Expand Virtual Servers. Click
server. On the Edit Virtual Server page, click the Add Property
button. In the Name column, type redirect_1.
If you are using Application Server 9.0, type
from=//myproduct1
url-prefix=/mywarname/mypages/products/myproduct1.jsp in the Value
column.
Note - The value of the you provide here needs to
match the value of the context root specified in the web.xml or
application.xml file.
As #Tunaki says, you need use an apache and use the mod_rewrite.
also, you can use UrlRewriteFilter thats allows you to rewrite URLs before they get to your code.
For that, you need add to your maven file the dependency:
<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>4.0.3</version>
</dependency>
And add in your WEB-INF/web.xml file:
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Also, you have a big number of parameters specified in the documentation:
http://cdn.rawgit.com/paultuckey/urlrewritefilter/master/src/doc/manual/4.0/index.html#filterparams
http://localhost:8080/MyApp/search ----> search.html
http://localhost:8080/MyApp/results ----> results.html
http://localhost:8080/MyApp/browse ----> browse.html

Access Sitecore DB from API in Console application

I would like to accesss the sitecore DB and items from console application like
Sitecore.Data.Database db = Sitecore.Context.Database
or
Sitecore.Data.Database db = Sitecore.Data.Database.GetDatabase("master")
how do I configure and setup my console application to access the DB as above?
Thanks Everyone for the suggestion, I am really interested in config changes, I used webservice, but it has very limited methods. For example, if I would like create an Item with the template and insert the item with prepopulated value, there is no such option. The reason I am looking for the console apporach is I would like to import the contents from XML or excel sheet and push those to the sitecore tree, eventually use the scheduled task to run the console app periodically. I do not want to copy the entire web.config and app_config. If anyone has already done this, could you please post your steps and necessary config changes?
You have two options I think:
1) Import the Sitecore bits of a website's web.config into your console application's app.config, so that the Sitecore API "just works"
I'm sure I read a blog post about this, but I can't find the reference right now. (I will have another look) But I think the simple but long winded approach is to copy all of the <sitecore/> element and all the separate files it references. I'm fairly sure you can whittle this down to a subset of the config required for data access with a bit of thinking.
2) Don't use the Sitecore API directly, connect to a web service that exposes access to it remotely.
There are a few of these that already exist. Sitecore itself exposes one, Sitecore Rocks has one, and Hedgehog TDS has one too. And you can always write your own (since any web service running inside the Sitecore ASP.Net app can make database calls and report values back and forth - just remember to consider security if this web service might end up exposed externally for any reason)
John West links to some relevant stuff here:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/09/Getting-Data-Out-of-the-Sitecore-ASPNET-CMS.aspx
-- Edited to add --
I've not found the blog post I remember. But I came across this SO thread:
Accessing Sitecore API from a CLI tool
which refers to this blog post:
http://www.experimentsincode.com/?p=232
which I think gives the info you'll need for option 1.
(And it reminds me that, of course, when you copy the config stuff you have to copy the Sitecore binaries into your app's folder as well)
I would just like to expand on #JermDavis' post and note that Sitecore isn't a big fan of being accessed when not in a web application. However, if you still want to do this, you will need to make sure that you have all of the necessary configuration settings from the web.config and App_Config of your site in your console application's app.config file.
Moreover, you will never be able to call Sitecore.Context in a console application, as the Sitecore Context sits on top of the HttpContext which means that it must be an application and have a valid request for you to use it. What you are looking for is something more along the lines of Sitecore.Configuration.Factory.GetDatabase("master").
Good luck and happy coding :)
This sounds like a job for the Sitecore Item Web API. I use the Sitecore Item Web API whenever I need to access Sitecore data from the master database outside the context of the Content Management server or outside of the context of the Sitecore application. The Web API definitely does not allow you to do everything that the standard Sitecore API does but it can act as a good base and I now extend upon the Web API instead of writing my own custom web services whenever possible.
Thanks to JemDavis's advise.
After I copied the configuration and made changes to config section to get rid of conflicts. I copied almost all of Sitrecore, analytics and lucene dlls, it worked great.
Only thing you have to remember is, copy the app_config folder to the same location where your dlls are.
Thanks again JemDavis....

ActiveDirectoryMembershipProvider not accepting FQDN

We are trying to set up the ActiveDirectoryMemebershipProvider for an ASP.NET intranet application that is supposed to automatically sign the users into the application when it is accessed in the browser.
However the browser is sending the FQDN (MYDOMAIN\some.user) to the server and the ActiveDirectoryMemebershipProvider seems not to be able to be able to find the user based on the FQDN. However when we test the provider manually from code we found that if we try just the user name (some.user) the provider seems to be able to find the user.
Is there any setting or anything we can use to make the provider skip the domain part sent from the browser ?
Try setting atttributeMapUsername if you haven't and let me know if that works for you. When I didn't set this I had to specify my users in some.user#my.ldap.domain format.
My Web.config
<add name="MyADMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString"
attributeMapUsername="sAMAccountName"
enablePasswordReset="false" maxInvalidPasswordAttempts="1" passwordAttemptWindow="15"
passwordAnswerAttemptLockoutDuration="1" minRequiredNonalphanumericCharacters="0" attributeMapEmail="mail"
/>
In IIS, go to the properties of the website and set the default domain to "\". Not sure which version of IIS you are using so if IIS resets this on you, the other way to accomplish this is to simply prepend the domain part so that it is added automatically?
Is this a custom app you are using or a product? Trying to understand why it is working from code but not from app. If you wrote the app, I assume you can change it to mimic your code. If you did not write the app, what is it? The app (such as OWA or SharePoint) may have a custom way it wants this done.

Accessing SharePoint Web Services over Silverlight

I have a problem to access SharePoint Webservice over Silverlight.
An error occurred while trying to make a request to URI
'http://sample:8000/_vti_bin/Authentication.asmx'.
This could be due to attempting to
access a service in a cross-domain way
without a proper cross-domain policy
in place, or a policy that is
unsuitable for SOAP services. You may
need to contact the owner of the
service to publish a cross-domain
policy file and to ensure it allows
SOAP-related HTTP headers to be sent.
Please see the inner exception for
more details.
Some questions:
How do I correctly deploy clientaccesspolicy.xml over Sharepoint Designer? Simply open site in designer, add file and then publish?
The site where clientaccesspolicy.xml should be deployed use forms authentication. I wasn't able to use Sharepoint Designer to publish there. Because of that, I created new zone for this site, which use Windows Authentication and published clientaccesspolicy.xml there. Both use same content database, didn't ?
If clientaccesspolicy.xml will be published, how can I allow this file be accessed anonymously?
Regards
Anton Kalcik
Here answers to my question 1. and 2.:
In Sharepoint Designer you open the site over: File -> Open Site -> In text field "Site name:" type URL of your site. Than drag & drop clientaccesspolicy.xml in root of your site.
If you have Form Authentication, you don't need for this step create new zone (but for some reasons it can be useful). You simply open web browser and type URL of your site. Then fill up text fields (always with user that have administrator privileges) and check "Sign me in automatically". After that will Sharepoint designer use this credentials for specified URL.
If you can help me with question Nr. 3, or you have some other solution, how can I access clientaccesspolicy.xml from Silverlight, post it!
The way we handled this on our project was to use an HTTP Handler. We put the clientaccesspolicy.xml file in the _layouts directory (which is shared across sharepoint sites) using a feature (you can also just manually copy it there).
Then we added our HTTP handler to the web.config handlers section. In our handler we check to see if the request is for /clientaccesspolicy.xml and if so we rewrite the path:
if (path.ToLowerInvariant() == "/clientaccesspolicy.xml")
{
HttpContext.Current.RewritePath("/_layouts/clientaccesspolicy.xml");
}
I'm not sure if this will bypass the security so it might not fully address your issue. But at least it gives you a method to access this file.
That is fine.
It should be, provided you haven't setup a whole new site somehow.
It shouldn't be as that would be a security risk. If you need to authenticate via WindowsAuth for the services so should you for the clientaccesspolicy.xml.
Keep in mind that clientaccesspolicy.xml must be at the domain root. In your example it would have to availble from http://sample:8000/clientaccesspolicy.xml. If you can't open it from your browser at that URL, your Silverlight client won't find it either.
The easiest way to get the file in the right place is to just copy it there via FTP or explorer. The file should be available to anonymous users (read only of course).
I find more realeable way to implement sharepoint httpHandler: it returns all content of clientaccesspolicy.xml himself
public void ProcessRequest(HttpContext context) {
if (context.Request.Path.ToLowerInvariant() == "/clientaccesspolicy.xml") {
context.Response.Write(#"<?xml version='1.0' encoding='utf-8' ?><access-policy><cross-domain-access> "+
#"<policy> <allow-from http-request-headers='*'> <domain uri='*' /> </allow-from> <grant-to> "+
#"<resource path='/' include-subpaths='true' /> </grant-to> </policy> "+
#"</cross-domain-access> </access-policy>");
}
}

dotnetnuke up and running error

I developed a DotNetNuke application and hosted it on a web server. When I browse the site, I am getting the following error:
Server Error in '/' Application.
Runtime Error Description: An
application error occurred on the
server. The current custom error
settings for this application prevent
the details of the application error
from being viewed remotely (for
security reasons). It could, however,
be viewed by browsers running on the
local server machine.
Details: To enable the details of this
specific error message to be viewable
on remote machines, please create a
<customErrors> tag within a
"web.config" configuration file
located in the root directory of the
current web application. This
<customErrors> tag should then have
its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web> </configuration>
Notes: The current error page you are
seeing can be replaced by a custom
error page by modifying the
"defaultRedirect" attribute of the
application's <customErrors>
configuration tag to point to a custom
error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly"
defaultRedirect="mycustompage.htm"/>
</system.web> </configuration>
Can any one tell me how to resolve the problem...
The main problem here is that you aren't getting any detail about what the error. Any success achieved while troubleshooting this without exposing some more detail (or knowledge of your setup) is going to be pretty close to pure luck.
I would suggest following the instructions that this default error message is giving you and editing the web. config file. The file is named "web.config" and it lives in the root of the website.
Open the file and search for "RemoteOnly", you should see something that says customErrors mode="RemoteOnly". Change the "RemoteOnly" to "Off" and save the file. The next time you browse to the site you should see a more detailed error message. Please share that with us here in the form of an update to your current post or as a new question (which I recommend, as it technically will be a different question).
Also, I recommend making a backup copy of the web.config file first before making any changes.
You need to check if your ASP.NET is functional. Since you didnt post any details on your web server, i would recommend you check if you have .NET 2.0 installed and your web server is configured to use it.
You can run aspnet_regiis -i in the c:\WINDOWS\Microsoft.NET\Framework\v2.x.x.x. directory to re-register the aspnet modules.
You might also want to check if your virtual directories have the execute permission enabled.
When you say you "developed a DotNetNuke application" I need more information.
Did you develop a DotNetNuke MODULE?
If so, did you install it on a DotNetNuke site that was working before, but isn't now?

Resources