Prevent user from navigating directly to a page in silverlight - silverlight-4.0

Is there a way to prevent users from navigating directly to a page in Silverlight 4?
Thank you.

You can override the Page.OnNavigatingFrom method and cacel the navigation before it happens.

Related

How can I have 'guardRoute' run before 'mapUnknownRoutes' in Durandaljs Router?

I'm using the Router in Durandaljs to control routing in a SPA. In my application all routes are created dynamically. Therefore I use only mapUnknownRoutes for mapping all routes. The problem I have is that if the user navigates between different hashes in the same page, clicking on 'back' leads to unloading the current page - something I wish to prevent. I thought of doing this by using guardRoute and there return 'false' when navigation remains in the same page, but 'guardRoute' runs only after 'mapUnknownRoutes' hence does not prevent the unloading of the current page.
Any suggestions?
Thanks !
Elior

MVC4:Prevent the user to type and navigate any ControllerName/ActionName in the address bar

In my MVC application, I dont want any user to type in the address bar of the browser and navigate to any controller action directly.Can I enable this for the whole application?if yes ,How? Can you please let me know the concept name ?
Also I dont want to do that through Request.URLReferrer because it has its own security risks (per Avoiding user to navigate to a view by entering url in the browser)
Thanks in advance!
You need to use Custom Action Filter Attributes, See :
http://www.asp.net/mvc/tutorials/hands-on-labs/aspnet-mvc-4-custom-action-filters
****Updated:**
As Parsanna mentioned in comment,
You can use the [ChildActionOnly] attribute on your action method to make sure it's not called directly, or use the ControllerContext.IsChildAction property inside your action to determine if you want to redirect.
See :Asp.net mvc How to prevent browser from calling an action method?

how to navigate from MainPage.xaml to other page.

In my apllication there are two from.The default form that is the MainPage.xaml and another form called login.xaml.
I have a button on MainPage.xaml,and my requirement is when the user click that button the Login page should be navigated.
This is my first experience in silverlight can i get that easily understandable code.
this.NavigationService.Navigate(new Uri("/Pagename", UriKind.RelativeOrAbsolute));
In this give your xaml or aspx (/Pagename) only no need to mention .xaml or .aspx
Instead of navigating, you could use a Childwindow
Otherwise, I think, you would have to use the Silverlight navigation framework, but this is quite complex. I'd suggest you to first have a child window pop up if you want to do something!
On Button Event
this.Content=new Login();

Can we Use masterPage in silverlight4 application

Is it Possible to use masterpage with silverlight4 application?
The Silverlight navigation template project available in VS2010 gives you the equivalent of a master page in the form of MainPage.xaml.
There is no master page concept in silverlight. try using usercontrols and implement the master page. Iframe and silverlight controls should do the trick.
Anyways let us wait and hear from an expert if there is a better work around.

Windows phone Navigation issue

I have an application where from the MainPage.xaml I navigate to a page called say two.xaml.
In Two.xaml I then navigate to Three.xaml..
Now for Three.xaml I want to navigate back to the mainPage.Xaml.
In Three.xaml if I do
this.NavigationService.GoBack();
this.NavigationService.GoBack();
I get an InvalidOperationException.
If I do
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
the system will crate another instance of MainPage.xaml, which I do not want as it will lose its original state.
Anyone have solutions to this issue?
you can save the actual state for example in the State-Property of the PhoneApplicationService Class, then Navigate through your pages and when getting back to the MainPage you just implement the OnNavigatedTo()-method of the MainPage and load the State-Data.
Hope this helps...
AFAIK, you are not supposed to manipulating the back stack in your app.
What cordellcp3 says may be a good idea to implement
If your intent is to navigate in this way:
MainPage->PageTwo->PageThree
User presses Back Button and goes to MainPage you can use this:
NavigationService.RemoveBackEntry()
documentation
hope it helps