I think I have just understood what you are trying to do.
I strongly feel you don't know enough about ASP.NET yet to achieve what you want to do. So I highly recommend going through more tutorials on codeproject and asp.net so that you can fully understand the MVC framework and how you use it.
ORIGINAL RESPONSE
You can post that information straight to you server if you want:
$(function () {
$.get("http://ipinfo.io", function (response) {
$.post("/MyController/Action", response);
}, "jsonp");
})
Razor is only for rendering the output. So once you view the page in the browser it will have ZERO ties to razor, i.e. no interaction with it.
My code doesn't load a partial, however, you can use JavaScript to render the UI once you've loaded the initial page (the one firing off the get to ipinfo). My code use jQuery to post the IP response to an action in MVC, so where mine says /MyController/Action, you replace with /Home/_ProductList. By the way you shouldn't really prefix an Action with "_"
So from what you are saying you want to load a partial, not an action, the comments confused me due to the code you were writing. Here is how I would do it:
@{
ViewBag.Title = "Products";
Layout = "~/Views/Shared/_Layout.cshtml";
string ip_address = "";
}
@Html.Partial("_ProductList");
<script type="text/javascript">
$(function () {
$.get("http://ipinfo.io", function (response) {
$.post("/MyController/Action", response.ip, function (successObj) {
// In here is where I set what ever in the partial
// I'm guessing that in the partial it renders some product table to view the products?
$.each(successObj, function (product) {
$("productTable").append(/* some new row using the product variable */);
});
});
console.log("ip+" + response.ip);
}, "jsonp");
});
</script>
string ip_addressno longer exists once its sent to the browser so you cant set it using javascript which runs on the client.