REgarding Return url in asp .net [closed] - returnurl

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
pseudocode :
declare a variable
store Return url in that variable.
if variable is not equal to null
redirect to returnurl
else
redirect to homepage.
can someone give me C# asp .net code for the above mentioned pseudocode as I'm completely new to progamming world???

string url="http://www.google.co.in/?gws_rd=cr" // variable declaration and assigning url to variable
if(url !="") // checking the string variable is empty or not
{
Response.Redirect(url); // variable is not empty redirect to given URL
}
else
{
Response.Redirect(HOMEPAGE URL); // else redirect to given home page
}
try this and let me now. it will helpful

Related

How to create bread crumb according to controller and action method [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I want to create breadcrumb in partial view . I want controller name and action method name in bredcrumb, how do i create it in partial view?
You can use the following:
var controller = ViewContext.RouteData.Values["Controller"];
var action = ViewContext.RouteData.Values["Action"];
<script>
$("li##(ViewContext.RouteData.Values["Controller"])/
#(ViewContext.RouteData.Values["Action"])")).addClass("active");
</script>
This will get you the current controller name and its view name you are in.
Reference from here:
https://stackoverflow.com/a/45479611/6029001

Handling status message upon submitting asp mvc form [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have been using asp MVC model state error when handling errors.
currently, I was using temp data as you see below:
TempData["message"] = "Successfully Added New Data.";
and rendered in all my views with forms.
I just want to ask any best practice that can be used when it comes to handling success message/status.
TIA!
If you are redirecting to another view you can use TempData collection. If you are staying on the same view, I would return current view with a flag in the model and then render it base on the value or just use ViewBag.
You should include the error or success message in the model you sent to the view.
Something like that:
public async Task<IActionResult> CityDetails()
{
MyModel MyModel = new MyModel();
MyModel.Message = "Successfully Added New Data.";
return View(MyModel);
}

submit values using partial view to database mvc 4 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to submit data using partail View.How do I do it? Can someone send simple sample code for understand it?
I want to create comment box as partail view.
If you give your Html here, it would have been helpful.
I recommend that you use the ID of the <input> tag and SUBMIT the value of it to your server via ajax call.
var comments = $('#Comment_Box_ID').val();
$.ajax({
type: 'post',
url: '/controller/method/',
data: comments,
success: function (data) {
// success code
},
error: function (e) {
// error code
}
});

How do I the site logo depending on the URL the request was made from? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I created a product registration page using ASP.Net MVC. I need to implement the same product registration page for subsidiaries (maybe 3 or 4) with a few minor changes to the way the site looks. For example, the logo will be different and some text at the top of the page. What is the best way to use the same codebase?
The best option I could come up with is passing HttpContext.Current.Request.URL to the view and using java script to update it.
However, I know routing can be an option too.
If you will be keeping the same .cshtml view for all registration pages then i think creating a partial view for logo generation would probably help you out.
Add another variable to your view model.. maybe call it subsidiary?
public int Subsidiary { get; set; }
then create a partial view called something like _LogoPartial.cshtml and in there do a if statement on the Subsidiary variable and return a different logo based on it
#model int
#if (Model == 1)
{
<img src="something" />
}
else if ...
then in your main view call it with
Html.RenderPartial("~/Views/Shared/_LogoPartial", Model.Subsidiary);

ASP.NET MVC Last visited data [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How to show Last Ten Pages Visited Cookie with asp.net mvc?
To store the url for each accessed page, you can use the Application_BeginRequest method of the global.asax, which will be called whatever the page accessed.
Example :
protected void Application_BeginRequest(object sender, EventArgs e)
{
string currentUrl = this.Context.Request.Url.AbsolutePath;
// Store the currentUrl to your database, for example
}

Resources