Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Getting error "Hmmm...can’t reach this page Try this Make sure you’ve got the right web address: https://localhost:5001"

$
0
0

Hello everyone!

My first post. Was thrown in the ring to write a razor app...

The app implements the PRG pattern whereby a search page is presented, the user enters a criteria, hits the search button and the result of the search is presented at the bottom of the same page. The items listed in the results table have a link that open a detail page, which has a "back" link to the first page. All that was working...I made some changes along the way and now when I run the app for the first time, it comes up. I enter the search criteria, hit the submit button and the page fails with 

"Hmmm...can’t reach this page

Try this Make sure you’ve got the right web address: https://localhost:5001..."

Below is a simplified version of the code in the page model.

[TempData]
 public string FileSearchCriteriaAuto { get; set; }
//...more code here
public void OnGet()
        {
            if (!String.IsNullOrEmpty(FileSearchCriteriaAuto))
            {
                FileSearchCriteria = JsonConvert.DeserializeObject<SearchCriteria>(FileSearchCriteriaAuto);

                HasSearch = FileSearchCriteria.FileName.Length > 0 || FileSearchCriteria.Criteria.Exists(c => c.Trim().Length  > 0);

                ContentSearchCriteria = new List<string>();
                ContentSearchCriteria.AddRange(FileSearchCriteria.Criteria);

                if (!(TempData == null))
                {
                    FileSearchCriteriaAuto = JsonConvert.SerializeObject(FileSearchCriteria);
                    TempData["FileSearchCriteriaManual"] = FileSearchCriteriaAuto;

                    if (TempData.ContainsKey("MatchedFilesJson"))
                    {
                        MatchedFiles = JsonConvert.DeserializeObject<List<FileProcessed>>(TempData["MatchedFilesJson"].ToString());
                        TempData.Keep();
                    }
                }
                FileName = FileSearchCriteria.FileName;
            }
            else
            {
                FileSearchCriteria = new SearchCriteria(string.Empty, 3);
            }

        }

        public async Task<IActionResult> OnPostAsync()
        {
            FileName = Request.Form["fname"].ToString().Trim();
            var elements = Request.Form.Where(e => e.Key.Contains("criteria")).ToList();
            ContentSearchCriteria = new List<string>();
            foreach (var ele in elements)
            {
                ContentSearchCriteria.Add(ele.Value.ToString().Trim());
            }
            FileSearchCriteria = new SearchCriteria(FileName, ContentSearchCriteria.ToList());

            string criteria = JsonConvert.SerializeObject(FileSearchCriteria);

            await LoadFilesAsync(FileName);

            MatchedFilesJson = JsonConvert.SerializeObject(MatchedFiles);
            TempData["MatchedFilesJson"] = MatchedFilesJson;

            return RedirectToPage("/Index");
        }

NB: I have tried passing a parameter to the OnGet method, from a property decorated with the

[BindProperty(SupportsGet = true)]

. Then the browser cannot render the page, as if the link is broken. 

Does anyone know why the page won't open? Thank you in advance!


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>