# Startup Navigation to View based off of IP Address

**URL:** <https://forum.inductiveautomation.com/t/startup-navigation-to-view-based-off-of-ip-address/81739>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [November 9, 2023, 7:31pm UTC](https://forum.inductiveautomation.com/t/startup-navigation-to-view-based-off-of-ip-address/81739 "2023-11-09T19:31:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carly\_Jankowski](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@Carly\_Jankowski](https://forum.inductiveautomation.com/u/Carly_Jankowski)\
**Post date:** [November 9, 2023, 7:31pm UTC](https://forum.inductiveautomation.com/t/startup-navigation-to-view-based-off-of-ip-address/81739/1 "2023-11-09T19:31:55Z")

</div>

Hello, I am working to display specific views based off of a computer/HMI IP address on session startup.  
The Session startup script is:

```auto
def onStartup(session):
	ip = session.props.address
	view = nav.handleStartup(ip)
	system.perspective.navigate(view=view)

```

With corresponding scripts:

```auto
# IPMapping
IP_TO_HMI_MAPPING = {
	"192.168.57.234":1,
        # 2-12 here...,
	"192.168.57.250":13 #this is the main computer
}

```

```auto
def handleStartup(ip):
	import system.perspective
	hmiNumber = IPMapping.IP_TO_HMI_MAPPING.get(ip, 'Unknown')
	if hmiNumber in range(1,13):
		return "HMI_Screens/Main_Screen"
	elif hmiNumber == 13:
		return "Main/Main"
	else:
		return "Unknown_View"

```

When I launched a session on my localhost, I expected to see my "Unknown\_View" view, but I just see a blank screen.  
I get the following error in my logs on the gateway:  
java.lang.IllegalArgumentException: No perspective page attached to this thread.  
Should there be a change script on the session property instead? Open to any suggestions.

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [November 9, 2023, 10:50pm UTC](https://forum.inductiveautomation.com/t/startup-navigation-to-view-based-off-of-ip-address/81739/2 "2023-11-09T22:50:24Z")

</div>

I believe Perspective needs to have a page open, because that provides the URL. So passing a view into `system.perspective.navigate` on startup won't work because no pages are open yet. I'd suggest making your startup views pages instead.

---

<div class="post-metadata">

**Author:** ![MSviga](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MSviga](https://forum.inductiveautomation.com/u/MSviga)\
**Post date:** [November 10, 2023, 6:32am UTC](https://forum.inductiveautomation.com/t/startup-navigation-to-view-based-off-of-ip-address/81739/3 "2023-11-10T06:32:02Z")

</div>

Depending on how your project is built you could use the Page Startup script. Can confirm that the system.navigate function works in there. As per the docs, the Page Startup event script only executes " when a Perspective page _starts_ in a new tab or window". So you will probably have to start the script with a condition checking if you want to execute the script or not. You can do that by accessing the Page ID property (`page.props.pageId`) or the page path property (`page.props.path`).
